Concurrency in Java using synchronized blocks not giving expected results
Below is a trivial java program. It has a counter called "cnt" that is incremented and then added to a List called "monitor". "cnt" is incremented by multiple threads, and values are added to "monitor" by multiple threads. At the end of the method "go()", cnt and monitor.size() should have the same value, but they don't. monitor.size() does have the correct value. If you change the code by uncommenting one of the commented synchronized blocks, and commenting out the currently uncommented one, the code produces the expected results. Also, if you set the thread count (THREAD_COUNT) to 1, the