Linked Questions

5 votes
3 answers
976 views

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 ...
crazyStart's user avatar
1 vote
1 answer
536 views

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....
user3808922's user avatar
2 votes
0 answers
300 views

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: ...
Babbara's user avatar
  • 486
0 votes
2 answers
296 views

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 ...
J86's user avatar
  • 15.4k
2 votes
0 answers
95 views

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:...
javaq's user avatar
  • 131
1 vote
0 answers
98 views

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 ...
Alex's user avatar
  • 633
0 votes
1 answer
73 views

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 ...
xXSpaghett69Xx's user avatar
0 votes
1 answer
56 views

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 ...
user101's user avatar
  • 11
0 votes
2 answers
65 views

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 ...
yash's user avatar
  • 151
0 votes
0 answers
31 views

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; ...
ywy144's user avatar
  • 1
0 votes
0 answers
22 views

synchronized (lock) { //lock.notifyAll(); new Thread(() -> { System.out.println("同步代码块中创建线程..."); try { lock.wait(); } ...
XrazYang's user avatar
5 votes
2 answers
5k views

public class Bees { public static void main(String[] args) { try { new Bees().go(); } catch (Exception e) { System.out.println("thrown to main" + e); ...
Avinash Jadhav's user avatar
3 votes
5 answers
4k views

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 ...
One Two Three's user avatar
-1 votes
2 answers
3k views

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 ...
Tomáš Zato's user avatar
0 votes
2 answers
2k views

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 . ...
Sumeet Kumar Yadav's user avatar

15 30 50 per page