This is the second part of the article published earlier - EvenOddVariants
This article suggests different ways in which co-ordination can be achieved between two or more threads using even and odd number generation as an example.
This article makes use of the java.util.concurrent.locks package to show how the co-ordination can be brought about.
There are four ways shown here:
1) Using the synchronized keyword and acquiring a lock on a common resource.
2) Using the Lock interface and then acquiring/releasing the common lock[Object that implements Lock] by calling locking/unlocking methods on it.
3) Using two objects and bringing about co-ordination between them and among the two threads using wait() and notify() methods.
4) Using two Lock objects and then obtaing corresponding Condition objects associated with them and bringing about co-ordination between them and among the two threads using await() and signal() methods.
PS: The third method has been re-mentioned [appeared in Part-1] to describe the usage in-contrast to usage of Locks.