Posted on 2001-06-18
i am having a problem with NOTIFY and WAIT. when i create a thread using :
new ABC().start() ... where ABC class extends Thread.i guess since i am always doing NEW of ABC() for all threads a new instance variable is declared .... so i gues my NOTIFY and WAIT doesn't work .... my NOTIFY and WAIT WORK when i create only one RUNNABLE object and pass the same object to all the threads.
Now i have figured out that if i create only one instance of Runnable object (i.e ABC() implements Runnable) .... my notify and wait works fine since all the thread share same instance variable and i can lock and realease on the ONLY instace that is shared by all the threads.
But i have a problem here ... now if i wanna set a parameter for each thread like : new ABC(params ..) ... i will have to do NEW ABC() everythime and i guess my notify and wait will NOT WORK ...