LinkedBlockingQueue
String abc = "abc" ;
analyzerBuffer.offer(abc);
List
analyzerBuffer.drainTo(tmp);
System. out .println(tmp);
System. out .println(analyzerBuffer);
analyzerBuffer.offer(abc);
analyzerBuffer.offer(abc);
analyzerBuffer.drainTo(tmp);
System. out .println(tmp);
System. out .println(analyzerBuffer);
输出:
[abc]
[]
[abc, abc, abc]
[]