Alright.. Hello everyone..
Its a very simple code.. Two threads.. One puts and one takes out from the array.. Both wait on size condition of being full and empty respectively
Size of Array is 2
Now the question is when i try to put 3rd element.. it waits(100 ms) on it as there is no space..
Now Thread2 runs and pulls out a value..I have made it to sleep for 300 ms before signaling..
When Put will acquire the lock again.. The Return value should be false.. but its true in many cases... Can't figure out why ??
JavaDoc of await
await
boolean await(long time,
TimeUnit unit)
throws InterruptedException
Causes the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses. This method is behaviorally equivalent to:
awaitNanos(unit.toNanos(time)) > 0
Parameters:
time - the maximum time to wait
unit - the time unit of the time argument
Returns:
false if the waiting time detectably elapsed before return from the method, else true
Example:
Thank you very much...(I can show the output if needed)