Originally posted by Nikos kat:
How do you use the object.wait() method. if you put a number in parenthesis is it the wait in milliseconds?
Is this as good as using Thread.wait()
Originally posted by faisal usmani:
Now as we know wait() is a method in Object class if you want call wait on Object you have to implement it something like this .
Object ob = new Object();
ob.wait();
There is no emoticon for what I am feeling!
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
There is no emoticon for what I am feeling!
Originally posted by Jeff Albertson:
When I try to run the codes you suggested:
The code blocks forever. What could be wrong?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
And I'm not entirely sure if Jeff is asking these questions for his own benefit, or to try to get Faisal to think more about his answer.
There is no emoticon for what I am feeling!
Originally posted by lakshmi v.samy:
Hi,
I have read the previous discussion
I tried with notify() and notifyAll()
notify() method is notifying the thread who is waiting at first posisition.
if I use notifyAll() method,it should notify to thread who is having highest priority in the queue.
but it is not happening like that,first thread is getting notification.
There is no emoticon for what I am feeling!
Originally posted by lakshmi v.samy:
notify() method is notifying the thread who is waiting at first posisition
Originally posted by lakshmi v.samy:
if I use notifyAll() method,it should notify to thread who is having highest priority in the queue.
Originally posted by lakshmi v.samy:
but it is not happening like that,first thread is getting notification.
Originally posted by vu lee:
Notification actions occur upon invocation of methods notify and notifyAll. Let thread t be the thread executing either of these methods on object m, and let n be the number of lock actions by t on m that have not been matched by unlock actions
Could some one throw more light on the bold phrase?
17.8.2 Notification
Notification actions occur upon invocation of methods notify and notifyAll. Let thread t be the thread executing either of these methods on object m, and let n be the number of lock actions by t on m that have not been matched by unlock actions. One of the following actions occurs.
* If n is zero an IllegalMonitorStateException is thrown. This is the case where thread t does not already possess the lock for target m.
* If n is greater than zero and this is a notify action, then, if m's wait set is not empty, a thread u that is a member of m's current wait set is selected and removed from the wait set. (There is no guarantee about which thread in the wait set is selected.) This removal from the wait set enables u's resumption in a wait action. Notice however, that u's lock actions upon resumption cannot succeed until some time after t fully unlocks the monitor for m.
* If n is greater than zero and this is a notifyAll action, then all threads are removed from m's wait set, and thus resume. Notice however, that only one of them at a time will lock the monitor required during the resumption of wait.
The synchronized statement (�14.19) computes a reference to an object; it then attempts to perform a lock action on that object's monitor and does not proceed further until the lock action has successfully completed. After the lock action has been performed, the body of the synchronized statement is executed. If execution of the body is ever completed, either normally or abruptly, an unlock action is automatically performed on that same monitor.
A synchronized method (�8.4.3.6) automatically performs a lock action when it is invoked; its body is not executed until the lock action has successfully completed. If the method is an instance method, it locks the monitor associated with the instance for which it was invoked (that is, the object that will be known as this during execution of the body of the method). If the method is static, it locks the monitor associated with the Class object that represents the class in which the method is defined. If execution of the method's body is ever completed, either normally or abruptly, an unlock action is automatically performed on that same monitor.
I am guessing n is the number of times the lock has been acquired.
Consider Paul's rocket mass heater. |