I can\'t figure out why the code doesn\'t work properly. The problem is that ReentrantLock doesn\'t lock methods invocation in ThreadClass.run()
Resource-class w
You are creating a new ReentrantLock per runnable meaning there is no synchronization. You will need to share the one lock with each Runnable instance.
ReentrantLock