2014-02-27, 08:06 PM
happylight Wrote:Jedward Did you figure this out? You just need to figure out when threads need to wait and when they need to notify another thread.
Dealer/CardGame/Main thread: Notify players when it's their turn. Wait during their turn.
Player: Wait when it's not my turn. Notify dealer when my turn is over.
I've been stewing over this while working on other things these past few days.
Game's working but not threaded properly. I keep getting IllegalMonitorStateExceptions when I try to implement the wait/notify system, assuming it's because I haven't figured out exactly where wait() and notify() should go in.
I guess I still haven't figured out the question I posed at the very beginning of this thread: Can I wake up a specific thread instead of being at the mercy of luck? If so, how?
The run() functions here are copypasted from the first post, with comments on where I would put wait() functions to help explain my thought process.
CardGame.java
Dealer.java
Player.java
Cleaned up first post and this post to reflect the new code. Currently the game works, but isn't actually using multithreading.

