Happens before between threads and atomic variable Part 2
问题 Since answer to Happens before between threads and atomic variable was that the asserts don't hold, I need an alternate implementation. Thread1 and Thread2 each update Integers t1 and t2 respectively. Once they are updated no other updates occur to t1 or t2. The values assigned to t1 and t2 come from a common counter which gets incremented after each assignment. I need to ensure the following asserts are true; int cnt=0; ReentrantLock lock = new ReentrantLock(); volatile Integer t1=null;