Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java threads and synchronization
#8
Jedward Wrote:So the loop solution is...

Code:
        while((!player1.hasWon) && (!player2.hasWon)){
            
        }

?

Yes

Quote:At the moment, when I run the code, nothing happens after the threads are started. Both are waiting to be woken up. What wakes them up, I don't know.

Try notify or notifyAll.

I never realised that `wait` is a form of sleeping in Javaland.
Reply


Messages In This Thread
Java threads and synchronization - by Jedward - 2014-02-20, 08:49 PM
Java threads and synchronization - by Locked - 2014-02-20, 09:05 PM
Java threads and synchronization - by Jedward - 2014-02-20, 09:09 PM
Java threads and synchronization - by Locked - 2014-02-20, 09:17 PM
Java threads and synchronization - by Jedward - 2014-02-20, 09:45 PM
Java threads and synchronization - by Locked - 2014-02-20, 09:59 PM
Java threads and synchronization - by Jedward - 2014-02-20, 10:08 PM
Java threads and synchronization - by Locked - 2014-02-20, 10:09 PM
Java threads and synchronization - by happylight - 2014-02-25, 07:07 PM
Java threads and synchronization - by Jedward - 2014-02-27, 08:06 PM
Java threads and synchronization - by happylight - 2014-02-28, 10:02 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)