Thread synchronization in java runner