i m new to java ... i have read many aticles on net regarding wait() and notify() but unable to get ..can you please make me understand about these two method with example
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
i m new to java ... i have read many aticles on net regarding wait() and notify() but unable to get ..can you please make me understand about these two method with example
Reading articles is the first step, perhaps 10% of the process of learning. Us giving you more to read doesn't make that 10% any bigger. The other 80 - 90% is putting what you've read into practice, right and wrong, through coding. Show us what you've tried and ask any questions you have about the results.
hi sir can you provide me a best site(url) for java Thread from which i gain more ..
A good start is Lesson: Concurrency (The Java™ Tutorials > Essential Classes)
Some more you can get from articles like Java 101: Understanding Java threads, Part 1: Introducing threads and runnables | JavaWorld
If you want to go more more deeper, buy "Java Concurrency in Practice", by Addison-Wesley Professional.
Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code
wait()-- It is used to send the running thread into waiting mode, means stand by mode.
notify()-- It is used to send waiting thread into "Ready State Queue", means it will put the waiting thread into "Ready Queue"
@chsvravikumar@gmail.com: Please check the most recent response date on threads. If a thread has been dormant for ~> 1 month, it's dead, the OP has moved on and probably doesn't care anymore.
However, if you have a gem of a good idea that you want to share with someone trying to do the same thing who may happen by someday, then by all means add it. (In this case, your post is not an example of such a gem.)
wait( ) tells the calling thread to give up the monitor and go to sleep until some other
thread enters the same monitor and calls notify( ).
notify( ) wakes up the first thread that called wait( ) on the same object.
Both the methods are used to block the thread for particular time interval until a specific condition is met. The necessity is that you need to ensure that any calls to wait() or notify() are within a synchronized area of code.
wait() : Causes current thread to release the lock and wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.
notify() : Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation.
Three years old thread closed.
If you don't understand my answer, don't ignore it, ask a question.