Develop the class ThreadSeqID with the static method get() that returns the ID of the calling thread. IDs are progressive int values, >=0, to be assigned according to the request order.
Define the interface for a shared counter.
Develop a program that, making use of a shared counter that is not thread-safe, clearly shows the problems deriving from data races.
Develop a correct version of the previous program (with a thread-safe shared counter).
Develop a version of the previous program with an implementation of the (shared) counter based on ThreadLocal.
Implement a Lock to be used by only two threads, recurring to the Peterson's algorithm. Use such Lock in a program where two threads concurrently make use of a shared data structure, assuring a proper access.