i' m getting this exception but i don't understand why.
public Test() {
globalLock = new ReentrantLock();
condition = globalLock.newCondition();
}
public void increaseRow(Integer row) {
matrixLock.lock();
try {
while (countIncreasingColumn > 0)
condition.await();
countIncreasingRow++;
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
condition.notifyAll();
matrixLock.unlock();
synchronized (rows.get(row)) {
for (int j = 0; j < column; j++)
matrix[row][j] += 1;
countIncreasingRow--;
}
}
}
thread class:
public void run() {
while (true) {
test.function(new Random().nextInt(10));
}
}
stackTrace:
Exception in thread "Thread-0" waiting thread for test 18
java.lang.IllegalMonitorStateException
at java.lang.Object.notifyAll(Native Method)
i' m getting thie exception on notifyAll()
. The thread that execute the global.lock()
block is the owner,so why i'm getting this?