I have a Java program which creates two threads each one executing the same code (the same run()).
My first Thread1 executes wait() on some monitor and is suspended until the second thread Thread2 calls notify on the same monitor.
My main looks like:
{
// Create threads
GameOfLifeThread[][] threads = new GameOfLifeThread[vSplit][hSplit];
for(int i=0; i<vSplit; i++){
for(int j=0; j<hSplit; j++){
threads[i][j] = new GameOfLifeThread(initalField, ...);
}
}
// Run threads
for(int i=0; i<vSplit; i++){
for(int j=0; j<hSplit; j++){
threads[i][j].run();
}
}
return ...;
}
The run() function looks like:
{
...
synchronized (bordersReadyForRead) {
...
bordersReadyForRead.wait();
}
...
}
The main thread continues to execute the run() of the first thread created and goes waiting. By some unknown reason the second thread doesn't starts at all!
What can be the reason for this problem?
Thank you in advance.