FAQ Database Discussion Community


Multiple conditions vs Multiple locks

java,multithreading,concurrency,locking,reentrantlock
For a particular thread-safe data structure, I am needed to protect access to a central data structure (namely a byte array). I am choosing to use ReentrantLocks in this case for it's fairness policy as well as advanced capabilities with creating multiple conditions. The conditions for concurrency are complex and...

Communication between threads in Java without lock

java,multithreading,condition,reentrantlock
So what i want to achieve is two threads taking turn in executing their task. I originally had just one question; How can i achieve two threads taking turns in executing their task without using a lock? Reason why i don't want the lock is because I'm feeling stupid, using...