se.ikama.bauta.sample.ConcurrentTest Maven / Gradle / Ivy
package se.ikama.bauta.sample;
import java.util.LinkedHashSet;
import java.util.concurrent.*;
public class ConcurrentTest {
LinkedBlockingQueue queue = new LinkedBlockingQueue<>();
public void add(Long l) {
if (!queue.contains(l)) {
queue.add(l);
}
}
public Long poll() {
return queue.poll();
}
public static void main(String args[]) {
ConcurrentTest ct = new ConcurrentTest();
ct.add(3L);
ct.add(2L);
ct.add(1L);
ct.add(1L);
ct.add(1L);
ct.add(1L);
ct.add(1L);
System.out.println(ct.poll());
System.out.println(ct.poll());
System.out.println(ct.poll());
System.out.println(ct.poll());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy