ublic class ClientSocket {
PriorityQueue<Integer> sample = new PriorityQueue<>();
public void start() {
new Thread(new Runnable() {
public void run() {
while(true) {
sample.add(new Integer(12));
System.out.println("Add=>"+sample.size());
}
}
}).start();
}
public void readList() {
System.out.println("Add size=>"+sample.size());
System.out.println(sample.poll());
}
public static void main(String args[]) {
ClientSocket cs = new ClientSocket();
cs.start();
cs.readList();
}
}
PriorityQueue<Integer> sample = new PriorityQueue<>();
public void start() {
new Thread(new Runnable() {
public void run() {
while(true) {
sample.add(new Integer(12));
System.out.println("Add=>"+sample.size());
}
}
}).start();
}
public void readList() {
System.out.println("Add size=>"+sample.size());
System.out.println(sample.poll());
}
public static void main(String args[]) {
ClientSocket cs = new ClientSocket();
cs.start();
cs.readList();
}
}