# HG changeset patch # User nobuyasu # Date 1310116027 -32400 # Node ID a60ec7414931423ba64d71567ccf7d56abc45118 # Parent b2604c5c6a2506ecbdba62894fd50c1619fedafc# Parent 9250cacee347aa84cc58cedde0d64f20677c00a1 merge diff -r b2604c5c6a25 -r a60ec7414931 src/test/MultiThreadTee.java --- a/src/test/MultiThreadTee.java Fri Jul 08 18:06:22 2011 +0900 +++ b/src/test/MultiThreadTee.java Fri Jul 08 18:07:07 2011 +0900 @@ -1,17 +1,20 @@ package test; import java.util.LinkedList; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.SynchronousQueue; public class MultiThreadTee { static class Parent extends Thread { - LinkedList> clients = new LinkedList>(); + LinkedList> clients = new LinkedList>(); - SynchronousQueue accept() { + BlockingQueue accept() { - SynchronousQueue s = new SynchronousQueue(); + // BlockingQueue s = new LinkedBlockingQueue(); + BlockingQueue s = new SynchronousQueue(); clients.add(s); return s; @@ -20,7 +23,7 @@ } void put(String s) throws InterruptedException { - for (SynchronousQueue queue : clients) { + for (BlockingQueue queue : clients) { queue.put(s); } @@ -33,7 +36,7 @@ static class Client extends Thread { Parent p; - private SynchronousQueue queue; + private BlockingQueue queue; @@ -48,8 +51,14 @@ String item; // while(!(item = queue.poll()).equals("") ) { while(true) { - item = queue.poll(); - if(item == null) continue; + try { + item = queue.take(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + // System.out.println("wating"); + continue; + } + // if(item == null) continue; if(item.equals("")) return; System.out.println(item); } diff -r b2604c5c6a25 -r a60ec7414931 src/test/MulticastQueue.java --- a/src/test/MulticastQueue.java Fri Jul 08 18:06:22 2011 +0900 +++ b/src/test/MulticastQueue.java Fri Jul 08 18:07:07 2011 +0900 @@ -14,7 +14,6 @@ Runnable type2 = new Runnable(){ - @Override public void run() { Client client = queue.newClient(); @@ -34,7 +33,6 @@ Runnable thread = new Runnable(){ - @Override public void run() { Client client = queue.newClient();