-
Threaded Object(s)
Hi
Hoping someone can help with this
Scenario : I have threaded objects on a wait method when the condition becomes true 3 threads are active.
I want to let 2 or less through my condition but the other runnable/running thread disappears and I lose it.
Any advice on how I might achieve this
Thanks for looking
-
Re: Threaded Object(s)
What have you tried? Where are you stuck? Where's your SSCCE?
Recommended reading: Lesson: Concurrency (The Java™ Tutorials > Essential Classes)
-
Re: Threaded Object(s)
Hi Kevin
synchronized void doSomething(Object x)
{
if(x.doThis()!=this.doThat())
{
try
{
wait();
}
catch(InterruptedException anException)
{
System.out.print("Error" + anException);
}
}
if statement goes here (I think)
The Threads are held in a List collection
This is the the condition I am trying to achieve :
if(theList<3 then do something) .........2 threads go through but one is let through the condition and it is lost
(3 threads will always wake at the same time)
In my other sychronized method I have a notify all to wak the threads up.
-
Re: Threaded Object(s)
Can you make a small complete program the compiles, executes and shows the problem.
Thread problems can be complex and require more than a few lines of code to resolve.
Be sure to wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting