Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


neelam
Thread method
1 Answer(s)      3 years and 10 months ago
Posted in : Java Interview Questions


What is the purpose of the wait(), notify(), and notifyAll() methods?

Advertisement
View Answers

October 19, 2010 at 4:23 PM


Hi,

 Here is the answer.

Java includes an elegant inter process communication mechanism via the wait( ), notify( ), and notifyAll( ) methods.

These methods are implemented as final methods in Object, so all classes have them. All three methods can be called only from within a synchronized method.

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.

Thanks.



Related Tutorials/Questions & Answers:
Thread method
Thread method  What is the purpose of the wait(), notify(), and notifyAll() methods
Java Thread : toString() method
Java Thread : toString() method In this section we are going to describe toString() method with example in java thread. toString() method : If you want... and thread group. Example :In this example we are using toString() method
Advertisements
Java Thread : setDaemon() method
Java Thread : setDaemon() method In this section we are going to describe setDaemon() method with example in java thread. Daemon Thread  : In Java.... public final void setDaemon(boolean on) : This method sets user thread either
Java Thread : isAlive() method
Java Thread : isAlive() method In this tutorial you will learn how to use isAlive() method in java thread. isAlive() method : When you are running many... of your thread dead. This can be checked by using method Thread.isAlive(). boolean
Java Thread : isDaemon() method
Java Thread : isDaemon() method In this section we are going to describe isDaemon() method with example in java thread. Daemon Thread  : In Java Thread, daemon threads are used to perform services for user threads. You can
sleep method in thread java program
sleep method in thread java program  How can we use sleep method... method .After that interval thread will awake.   public class test... Description:- In this thread example ,we have used sleep method. we are passing
Java Thread : yield() method
Java Thread : yield() method In this section we are going to describe yield() method with example in java thread. yield() Method: When you want to stop...() method of Thread. public static void yield() - This method pauses
Java Thread : run() method
Java Thread : run() method In this section we are going to describe run() method with example in java thread. Thread run() : All the execution code...() : By extending the Thread class, run() method is overridden and put all
Java Thread : stop() method
Java Thread : stop() method In this section we are going to describe stop() method with example in java thread. stop() method : Java thread provides method stop to stop any running thread. It is deprecated  as it causes
Java Thread : sleep() method
Java Thread : sleep() method In this section we are going to describe sleep() method with example in java thread. sleep() method : Suppose you want to stop your thread for a specific time period, you can use sleep() method
(help me) use wait() and notify() method in Thread.
(help me) use wait() and notify() method in Thread.   we have to create 3 classes..1 is the main class, 1 is Thread UUM class, and another one is Thread Sintok class...we have to use wait(); and notify(); to comes out
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
Thread
instance the thread is in this state but before the start() method invocation... after the invoking of start() method but a thread can return to this state after... ? A thread can be considered dead when its run() method completes. If any thread comes
thread
thread  can parent thread be dead if child thread is not dead
Thread
Thread  what is the use of thread
Thread
Thread  Thread Life Cycle
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
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
Java Sleep Thread
Java Thread sleep() is a static method. It sleeps the thread for the given time in milliseconds. It is used to delay the thread. It is used in Applet or GUI programming for animation Java Sleep Thread Example public class
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  what happen when we call the Wait(),Notify() and NotifyAll() methods in the Thread
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
Java Thread destroy
Java Thread destroy In this tutorial, we are using Thread.destroy() method... method to destroy the thread. In general, Thread.destroy() is dangerous...() : This method destroy your thread without any cleanup. The locked monitor remains lock
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
us to handle them. We can also use throws clause on the surrounding method
Java Current Thread
() method to find the current thread name. Thread.currentThread() : Thread class provides method to display the current running thread. It is static Thread method so that there is no need to call a reference to a Thread object
Java Thread Context
classloader to set a thread using Thread.setContextClassLoader() method... Thread Context       The Thread Context is required by the current thread from the group
Java Thread setName() Example
setName() method with example in java thread. Thread setName() :  Suppose... method setName(). You can add some new desired name to your thread. To display name of thread you can call getName() method. public final void setName(String
Java Thread getStackTrace Example
as the stack dump of the given thread. This method provides the array of stack trace...Java Thread getStackTrace Example This section explains use of getStackTrace() method  in java Thread. Thread getStackTrace() : It returns an array
Java :Thread Join
Java :Thread Join In this tutorial you will see how to use join method in java thread. join() method - join method waits until the thread die. If we... method of thread. public class ThreadJoin implements Runnable { Thread thread
Java Thread Join
Java Join method join the next thread at the end of the current thread After current thread stops execution then next thread executes. Java Join Thread Example public class join implements Runnable { @Override public
Java Thread IsInterrupt
() method with example in java thread. Thread IsInterrupt : If you want to check that your thread is interrupted or not, Thread class provide you method isInterrupted(). This method only check the interrupted status of the thread
Thread in java
Thread in java  which method will defined in thread class
Count Active Thread in JAVA
Count Active Thread in JAVA In this tutorial, we are using activeCount() method of thread to count the current active threads. Thread activeCount() : Thread class provides you to check the current active thread by providing
Java Thread checkAccess
permission of thread modification by using checkAccess () method. Thread checkAccess...() method throws a SecurityException if thread is not allowed to modify. public... changes to the thread by using checkAccess() method. class CheckAccess
Java thread
Java thread  What invokes a thread's run() method
Java Thread setName
Java Thread setName() method sets the new name to each Thread. It is used in both Thread class and Runnable interface. Name is also set by the string data used in the constructor. Java Thread setName Example public class
Create Thread by Extending Thread
() method, initialize the thread in its constructors. For beginning the execution of new thread call start() method. Example : In this example we are extending...Create Thread by Extending Thread This section explain how to create thread
JAVA Method Wait
; The Wait method in Java hold the thread to release the lock till the thread hold the object. The most important point is to be remember that wait method... - The other thread invoke the notify method for the this object
Thread restart
Thread restart  hello,, can dead thread restart?   hii, A dead Thread can't restart not even by calling start() again on that object
java Thread
java Thread  what is purpose of Thread
Daemon thread
Daemon thread  what is need of daemon thread
Daemon thread
Daemon thread  what is need of daemon thread
Java thread
Java thread  How can a dead thread be restarted?  A dead thread cannot be restarted
thread - Java Beginners
thread  can i asko for programs in thread method that will allow user to input two separate names  Hi friend, For more information on Thread visit to : http://www.roseindia.net/java/thread/index.shtml Thanks
Exception in Thread
Exception in Thread    i am developing a rmi application in eclipse... : Blockquote Exception in thread "RMI TCP Connection(idle...(Transport.java:158) at java.security.AccessController.doPrivileged(Native Method
Advertisements
 

 

 

DMCA.com