Thread

Thread

what happen when we call the Wait(),Notify() and NotifyAll() methods in the Thread?

View Answers

May 11, 2011 at 4:26 PM

The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource.

When you call the wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods.

* 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.
* notifyAll( ) wakes up all the threads that called wait( ) on the same object. The 
  highest priority thread will run first.









Related Tutorials/Questions & Answers:
thread
thread  can parent thread be dead if child thread is not dead
Thread
Thread  Thread Life Cycle
Advertisements
Thread
Thread  what is the use of thread
Thread
Thread  Explain two ways of creating thread in java. Explain at three methods of thread class.   Java Create Thread There are two main ways of creating a thread. The first is to extend the Thread class and the second
Thread
Thread  What is multi-threading? Explain different states of a thread... processor system. States of Thread: New state ? After the creations of Thread instance the thread is in this state but before the start() method invocation
Thread
to the thread constructor eventhough we had created only one thread and if you say we have added to point to the current thread then why we have not added this in the following line "s=s1" Pls reply...... class MyThread extends Thread { Thread
Thread
Thread  what happen when we call the Wait(),Notify() and NotifyAll() methods in the Thread
Thread
Thread  class Extender extends Thread { Extender(Runnable run...(); } public void run(){ System.out.println("Extender Thread is Started :"); //new Thread(new Implementer()).start(); } } class Implementer
Thread
Thread  will this code work..? class A extends Thread { public...=" + i); } public static void main(string args[]) { A a = new A(); Thread t = new thread(a); t.start(); } } Is it possible to run above program with out
Thread
Thread  Write a Java program to create three theads. Each thread should produce the sum of 1 to 10, 11 to 20 and 21to 30 respectively. Main thread....   Java Thread Example class ThreadExample{ static int
Thread
Thread   there are two threads running at a time.. when am updating a values in database. both thread halt and stop for moment till it get updated into database... so i dnt want thread to get halts for tht moment of period. whats
Thread in java
Thread in java  which method will defined in thread class
Daemon thread
Daemon thread  what is need of daemon thread
Daemon thread
Daemon thread  what is need of daemon thread
java Thread
java Thread  what is purpose of Thread
Java thread
Java thread  How can a dead thread be restarted?  A dead thread cannot be restarted
Thread restart
Thread restart  hello,, can dead thread restart?   hii,ADS_TO_REPLACE_1 A dead Thread can't restart not even by calling start() again on that object
Java thread
Java thread  What's the difference between a thread's start() and run() methods
Java thread
Java thread  What is the difference between process and thread
Java thread
Java thread  What invokes a thread's run() method
Thread method
Thread method  What is the purpose of the wait(), notify(), and notifyAll() methods
Java thread
Java thread  What are the ways in which you can instantiate a thread
Java thread
Java thread  What are the high-level thread states
Demon thread
Demon thread  What is demon thread? why we need Demon thread?  ... there are daemon thread by killing them abruptly.Any thread can be a daemon thread... = window.adsbygoogle || []).push({}); http://www.roseindia.net/java/thread/daemon
Thread scheduling
Thread scheduling  What is the algorithm used in Thread scheduling?  Java uses fixed-priority scheduling algorithms to decide which thread... on the basis of their priority relative to other Runnable threads. The thread
daemon thread
daemon thread  hello, What is a daemon thread?   hello,ADS_TO_REPLACE_1 These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly
Create Thread by Extending Thread
Create Thread by Extending Thread This section explain how to create thread by extending Thread class in java. Extending Thread : You can create thread by extending Thread class and then by creating instance of that class you can
Java thread
Java thread  Why do threads block on I/O?   When a thread... and in that time some other thread which is not waiting for that IO gets a chance to execute.If any input is not available to the thread which got suspended for IO
Thread in Nutshell
Thread in Nutshell  Hi, I m confused about what is called a thread actually in a program. There are many answer to this question on the web...; Please go through the following link: Thread Tutorials
Main Thread and Child Thread
and Child Threads used in Programming. Main thread is automatically created when program runs. Child Thread gets created by the main thread . Java Main Thread Example public class mainchild implements Runnable { Thread t1
Thread concept
Thread concept  Everytime when i run a multithread program it gives... in advance friends. Happy new year!!!!! class Newthread3 implements Runnable{ Thread t; String name; Newthread3(String threadname){ name=threadname; t=new Thread
Exception in thread
Exception in thread   Hi, In my code following error is coming: Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject I have imported: import org.json.JSONObject; but its not working. What
thread dump
thread dump  Hi, I wanted to understand the Locked/waiting state below in the java thread dump. Is it normal to have waiting on locked object monitor value to be same, in the snippet below both are<0x701dd1e0> i see a lot
Exception in thread
Exception in thread   Hi, In my code following error is coming: Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject I have imported: import org.json.JSONObject; but its not working. What
Version of excalibur-thread>excalibur-thread dependency
List of Version of excalibur-thread>excalibur-thread dependency
Exception in thread
Exception in thread   Hi, I have created a java file for sending a file to my mail. I am using mail.jar file. I am able to create .class file...:\mail.jar SendMailTLSDFC Exception in thread "main" java.lang.NoClassDefFoundError
Exception in Thread
Exception in Thread    i am developing a rmi application in eclipse use genady rmi plugin and server side code run effeciently but when i run... : Blockquote Exception in thread "RMI TCP Connection(idle
Thread
Thread
thread
Thread
Is ActionServlet thread safe ?
Is ActionServlet thread safe ?  Is ActionServlet thread safe
Is ActionServlet thread safe ?
Is ActionServlet thread safe ?  Is ActionServlet thread safe
Java Thread and Runnable
Java Thread and Runnable  What's the difference between Thread and Runnable types
thread runtime process
thread runtime process  Java thread runtime process
How to Differenciate Main Thread and Child Thread in Java
How to Differenciate Main Thread and Child Thread in Java  hi... Main Thread and Java Child Thread. Please Suggest any example or online link...({});   Hi, There are two types of Thread used in Java Programming
Version of excalibur-thread>excalibur-thread-api dependency
List of Version of excalibur-thread>excalibur-thread-api dependency
Version of excalibur-thread>excalibur-thread-impl dependency
List of Version of excalibur-thread>excalibur-thread-impl dependency
Version of excalibur-thread>excalibur-thread-instrumented dependency
List of Version of excalibur-thread>excalibur-thread-instrumented dependency
Thread - Java Beginners
Thread creation and use of threads in JAVA  Can anyone explain the concept of thread, thread creation and use of threads in JAVA application?  Thread creation and use of threads in JAVA Java Resourcehttp

Ads