Have threads run indefinitely in a java application
Posted
by TP
on Stack Overflow
See other posts from Stack Overflow
or by TP
Published on 2010-06-06T11:13:23Z
Indexed on
2010/06/06
11:22 UTC
Read the original article
Hit count: 223
I am trying to program a game in which I have a Table class and each person sitting at the table is a separate thread. The game involves the people passing tokens around and then stopping when the party chime sounds.
how do i program the run() method so that once I start the person threads, they do not die and are alive until the end of the game
One solution that I tried was having a while (true) {} loop in the run() method but that increases my CPU utilization to around 60-70 percent. Is there a better method?
© Stack Overflow or respective owner