Perhaps you really need a queue lock. When you create a thread, you pass the lock queue internally, and the thread should continue to check if there is any item in the queue. Outside a thread, you can queue items while the thread is "running." Blocking a queue can prevent a thread from exiting if not done.
public class Test { public static void main(String... args) { final BlockingQueue<String> queue = new LinkedBlockingQueue<String>(); Thread running = new Thread(new Runnable() { @Override public void run() { while (true) { try { String data = queue.take();
}
George
source share