communication between threads in java
Posted
by Noona
on Stack Overflow
See other posts from Stack Overflow
or by Noona
Published on 2010-05-12T03:48:52Z
Indexed on
2010/05/12
3:54 UTC
Read the original article
Hit count: 283
How can I make a thread run only if the other thread is running too, meaning, if I return from run in one thread, then I want the other to stop running too, my code looks something like this:
ClientMessageHandler clientMessagehandler = new ClientMessageHandler();
ServerMessageHandler serverMessagehandler = new ServerMessageHandler();
Thread thread1 = new Thread(serverMessagehandler);
Thread thread2 = new Thread(clientMessagehandler);
thread2.start();
thread1.start();
i want to cause thread1 to stop running when thread2 stops running.
thanks
© Stack Overflow or respective owner