コード例 #1
0
 public void run() {
   buffer.init();
   ready.release();
   for (int i = 0; i < 100; i++) {
     buffer.put(i);
   }
   buffer.finish();
 }
コード例 #2
0
 public void run() {
   producer.getReady();
   MyBlockingQueue<Integer> buffer = producer.getBuffer();
   Integer item = buffer.take();
   while (item != null) {
     System.out.println(this + " fetches " + item + ".");
     Thread.yield();
     item = buffer.take();
   }
 }