Here\'s my code:
private int count = 0;
public synchronized void increment() {
count++;
}
public void doWork() throws InterruptedException {
What actually happens is that your Threads are snapshotting (maybe a another word is better here) the current value of the variable count and display it. You can think of it like there is a blue bucket with the number zero and both Threads are getting the same bucket in the same color and number. They now work individually on those buckets.
If you want them to work on the same bucket, you have to make them atomic e.g. with AtomicInteger or volatile or any other tool from the java concurrent package.