Linked Questions
33 questions linked to/from IllegalMonitorStateException on wait() call
5 votes
3 answers
976 views
Print odd & even number using Multi threading [duplicate]
I am trying to learn Multi threading and for practice, I am trying to print odd & even number using two thread. I have created an object which will act as a lock for the both the threads. When I ...
1 vote
1 answer
536 views
java.lang.IllegalMonitorStateException occurs on calling wait(); in java [duplicate]
I have written this java code for a simple counter, there are two JButtons one for running counter and other one for stopping the counter, when I run my code and click wait button (java.lang....
2 votes
0 answers
300 views
Synchronizing Consumer - Producer with thread in java [duplicate]
I made this piece of code to try and understand the synchronization between threads in Java, but when I run it I get a java.lang.IllegalMonitorStateException exception. The condition of my code are: ...
0 votes
2 answers
296 views
Can not put a thread on wait() - IllegalMonitorStateException [duplicate]
Background: I have an application of miniature robots (these extend Thread class) that make deals with one another at nodes of a map. I am trying to program the logic that goes into the node. The ...
2 votes
0 answers
95 views
Unexpected IllegalStateMonitorException [duplicate]
Sometimes the below code throws IllegalStateMonitorException and sometimes it runs nicely. Not able to understand the scenarios how could it happen as it is always called under lock.lock(). Full Code:...
1 vote
0 answers
98 views
How to create user defined SettableFuture in java [duplicate]
I want to create a user defined SettableFutureObject. A user should call the get() method and has to wait until the Result-Object was set into this future object. My biggest problem is to make it ...
0 votes
1 answer
73 views
Trying to get a Thread to wait for an event to be received with the JDA, but I can't escape an IllegalMonitorStateException [duplicate]
I'm working on a small game to be played through discord by me and some friends. My code should theoretically work, but for some reason I can't escape the IllegalMonitorStateException "current ...
0 votes
1 answer
56 views
IllegalMonitorStateException in Java [duplicate]
I'm getting an IllegalMonitorStateException in my code. Inside startEmployeeProcess() method I start a thread1 (EmployeeThread) and inside the switch I call thread1.wait() (case 3) What is the ...
0 votes
2 answers
65 views
java thread understanding issue [duplicate]
Though my question sound like stupid.. Here is code for multiple thread : public class Main { private int x = -1; public Main(int xy) { this.setX(xy); } static Main main; public static void ...
0 votes
0 answers
31 views
Why does my code throw java.lang.IllegalMonitorStateException [duplicate]
I wonder why the following code throws java.lang.IllegalMonitorStateException when I lock myInt. package Thread; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; ...
0 votes
0 answers
22 views
Why does the following code throw an exception "IllegalMonitorStateException"? [duplicate]
synchronized (lock) { //lock.notifyAll(); new Thread(() -> { System.out.println("同步代码块中创建线程..."); try { lock.wait(); } ...
5 votes
2 answers
5k views
Exception in java for wait() method
public class Bees { public static void main(String[] args) { try { new Bees().go(); } catch (Exception e) { System.out.println("thrown to main" + e); ...
3 votes
5 answers
4k views
put the current thread to sleep and let others wake it
I have the follow method foo which takes an Observer and puts the current thread to sleep until the Observer wakes it up. For some reason, I keep getting java.lang.IllegalMonitorStateException ...
-1 votes
2 answers
3k views
Make a blocking thread for message queue
I'm making a simple server-client application. I'm handling the message queue this way (class MessageQueue): private Vector<String> messages; //Runs from any thread public void add(String ...
0 votes
2 answers
2k views
Java ExecutorService invokeAll multiple task resolv
I am using executer service to run task in parallel . The parallel running method takes input integer and returns integer . As parallel task has return type , so I have used Callable anonymous class . ...