List of usage examples for java.util.concurrent ConcurrentLinkedQueue remove
E remove();
From source file:io.covert.dns.collection.ResolverThread.java
public static void main(String[] args) throws Exception { ConcurrentLinkedQueue<DnsRequest> inQueue = new ConcurrentLinkedQueue<DnsRequest>(); AtomicLong inQueueSize = new AtomicLong(0); ConcurrentLinkedQueue<Pair<Record, Message>> outQueue = new ConcurrentLinkedQueue<Pair<Record, Message>>(); String[] nameservers = new String[] { "8.8.8.8" }; inQueue.add(new DnsRequest("www6.google.com.", Type.AAAA, DClass.IN)); inQueue.add(new DnsRequest("ipv6.google.com.", Type.AAAA, DClass.IN)); inQueue.add(new DnsRequest("gmail.com.", Type.AAAA, DClass.IN)); inQueueSize.incrementAndGet();// w w w. j a v a2 s . c o m inQueueSize.incrementAndGet(); inQueueSize.incrementAndGet(); ResolverThread res = new ResolverThread(inQueue, inQueueSize, outQueue, nameservers, 5); res.start(); res.stopRunning(); res.join(); Pair<Record, Message> result = outQueue.remove(); System.out.println(result); result = outQueue.remove(); System.out.println(result); result = outQueue.remove(); System.out.println(result); }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.ClientMonitor.java
private void write(PrintWriter out) { ConcurrentLinkedQueue<JSONObject> queue = dispatcher.getWriteQueue(); while (!shutdown) { if (queue.isEmpty()) { synchronized (queue) { try { queue.wait();//w ww . jav a2s . com System.out.println("CL-WRITE: Got something to write!"); } catch (InterruptedException ex) { } } } else { String w = queue.remove().toString(); //System.out.println("CL-WRITE: WRITING THIS:======================="); //System.out.println(w); //System.out.println("=============================================="); out.println(w); out.flush(); } } //System.out.println("CL-WRITE: Exiting, turning off the lights..."); try { close(); } catch (IOException ex) { Logger.getLogger(ClientMonitor.class.getName()).log(Level.SEVERE, null, ex); } }