Bilal :
I am bit new in Java Threading and concurrency. I have read about synchronized and lock blocks. They let other Threads to wait until first Thread complete its work.
I just want to know a way that if THREAD A is performing its execution, then THREAD B should not wait and skip the execution of that shared code block.
Andrew Tobilko :
Thread B could try to acquire the lock by Lock.tryLock
. If it's not available, Thread B may skip "the execution of that shared code block" immediately after the check.