I have noticed something very unusual with Java class.
If I instantiate a Condition (from a lock) in the class-body, it doesnt instatiate the object. Here is an example:
private class ConcurrentQ{
ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
Lock readLock = readWriteLock.readLock();
Lock writeLock = readWriteLock.writeLock();
Condition emptyList = readLock.newCondition(); //PROBLEM!
...
}
If I did ConcurrentQ q = new ConcurreqntQ()
, it would not instantiate, but if removed the //PROBLEM!
line it works fine.
Can I know why?