This discussion is archived
2 Replies Latest reply: Jul 5, 2012 1:45 PM by morgalr RSS

Developing Pools Game, Please Help!

946763 Newbie
Currently Being Moderated
I am developing a pools game. I have a thread checker which keeps on decreasing the numbers from 100 to 0. It stops when reaches 0 number. Sleeping time between subtractions is 5 seconds, it decreases like 100, 99, 98, 97…………so on.

I need to execute following situation:

->There are two classes class A and Class B with a main() method. They start thread in main(). It should be like if class A is running the Checker thread then class B thread should wait unless and until class A finishes its execution.
->If Checker thread in Class A is sleeping then thread of class B should not start. Class B thread only start when class A thread is stopped.

What should I do to implement such synchronization between class A and B?

Edited by: EJP on 1/07/2012 19:58: deleted extraneous matter
  • 1. Re: Developing Pools Game, Please Help!
    EJP Guru
    Currently Being Moderated
    ->There are two classes class A and Class B with a main() method.
    One main() method? Or one each?
    They start thread in main().
    Each? One of them? Both of them? In the same JVM? Different JVMs?
    if class A is running the Checker thread
    'The Checker thread' is meaningless. Do you mean a thread with that name? A thread whose Runnable is a class of that name? A class of that name which extends Thread?
    then class B thread should wait unless and until class A finishes its execution
    Its execution of that thread? Its entire JVM?
    ->If Checker thread in Class A is sleeping then thread of class B should not start. Class B thread only start when class A thread is stopped.
    Again, which thread? Identified how? In the same JVM? Its own JVM?

    You need to specify your problem a lot better than this.

    More importantly than any of the above, why? What is the actual problem being addressed? Thread safety? Single instance of the application? Sequential execution of tasks?
    >
    What should I do to implement such synchronization between class A and B?
  • 2. Re: Developing Pools Game, Please Help!
    morgalr Explorer
    Currently Being Moderated
    EJP wrote:
    More importantly than any of the above, why? What is the actual problem being addressed? Thread safety? Single instance of the application? Sequential execution of tasks?
    My bet is a homework problem.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points