answersLogoWhite

0


Best Answer

notify()

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which cannot directly cause a thread to stop executing?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What cannot cause a thread to stop execute?

A siren, flatulence, a spaghetti dinner, many other things.


Do thread worms cause weight gain?

No


When should the method invokeLater be used?

invokeLater should be used when your code is performing a GUI change in the Swing UI library, and you cannot guarantee that the change is being made in the Event Dispatching Thread (which can cause data problems, as Swing is not "thread-safe"). So, invokeLater should be used if (1) you are using Swing, and (2) you are using Thread, and (3) the thread from 2 needs to update a GUI element that is part of Swing.


Do thread worms cause pain and bloating?

In some cases it can cause bloating but they don't cause any pain.


Can crack cocaine kill a woman?

Whether directly or indirectly it has the possibility of being the cause of death.Whether directly or indirectly it has the possibility of being the cause of death.Whether directly or indirectly it has the possibility of being the cause of death.Whether directly or indirectly it has the possibility of being the cause of death.Whether directly or indirectly it has the possibility of being the cause of death.Whether directly or indirectly it has the possibility of being the cause of death.


can alcohol cause coronavirus?

Alcohol cannot directly cause coronavirus, but drinking in excess can weaken your immune system. Weaker immune systems are more likely to catch a virus while being spread.


Can constipation be inherited from parents?

Yes and no. A cause of constipation can be inherited from parents, grandparents, etc. Such a cause may be a thyroid deficiency. however constipation is a symptom of many disorders and diseases so it cannot be directly inherited as such.


How a infection affecting the respiratory system would directly threaten a person's health?

If you have an infection in the respiratory system then this can cause your airways to become restricted so that you cannot breath.


Can a hurricane be caused by a human?

No. Although it has been proposed that human-caused climate change may affect hurricane activity, humans cannot directly cause hurricanes.


What is a black thread-like substance in stool?

Have you been eating bananas lately? The center of the banana can cause this to happen sometimes. If you think you have a parasite take a stool sample and give it to your doctor.


What cannot cause paralysis in a dog?

bananas cannot cause paralysis in dogs.


Difference between yield method and sleep in java?

Thread.sleep(long milliseconds): The thread's sleep method sends the current thread into Non-Runnable state for the specified amount of time. But, this doesn't cause the thread to loose ownership of the acquired monitors. So, if the current thread is into a synchronized block/method, then no other thread will be able to enter that block/method.The Sleep method throws 'InterruptedException' if another thread interrupts it.There is another variant of the 'sleep()' method where it accepts two arguments - one, long milliseconds, and second, int nanoseconds. Simply put, this method causes the current thread to sleep for the specified number of milliseconds plus the specified number of nanoseconds. The second argument 'int nanoseconds' can acquire a value of the range 0-999999.wait() method: The wait() method also sends the current thread into Non-Runnable state like the sleep() method. But, the difference between the two is that in case of 'wait()' the locks are released before going into Non-Runnable state, so that any other thread that is waiting on the object can use it (Unlike the Sleep method - This is the big difference) Another apparent difference is that 'wait()' is an instance method, while sleep() is a static method. The method 'wait()' should be called for an object only when the current thread has already acquired lock for that object. This causes the current thread to wait either another thread invokes the 'notify()' method or the 'notifyAll()' method for this object, or a specified amount of time has elapsed and after that the thread starts participating in thread scheduling process to acquire the monitor of the object to proceed further.There are three variants of this method in the 'Object' class:-public final void wait(long timeout)public final void wait(long timeout, int nanoseconds)public final void wait()All the three methods throw InterruptedException & IllegalMonitorStateException. The first two may also throw IllegalArgumentException.The wait() method causes the current thread to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. After the execution of this method invocation, the thread becomes disabled for any scheduling purposes and lies dormant until one of the following things happen:-* Any other thread invokes 'notify()' method this object and the thread under consideration is arbitrarily chosen as the thread to be awakened. * Any other thread invokes 'notifyAll()' for this object. * Any other thread interrupts the thread under consideration. * The specified amount of time has elapsed (in case first two variants of wait() are used) After any of the four above mentioned events happens, the thread is removed from the wait set for this object and re-enabled for thread scheduling. It'll compete for the rights to synchronize on the object in an usual manner and it'll keep doing this until it acquires control on the object and gains all the synchronization claims on the object, which it had acquired at the time of 'wait()' invocation. This means that after the return from wait() method, the synchronization state of object and of the thread will be exactly the same as it was before the wait() invocation.