We have a Java multi threaded environment processing millions of records. In production, some threads have been observed to be hung, waiting for a synchronized method.. Work around was provided by removing dependency on synchronized method.
But, still unable to replicate the issue in Dev environment, that multiple threads are hung on a synchronized method. In Dev, all threads are completed in every attempt. Any suggestions how to replicate the issue in Dev to unit test the patch??
After more analysis, it seems the case of starvation.Any pointers on how to simulate starvation in executor framework ?
In your DEV environment as you could not create a production like environment to re-create the bug you need to introduce a long sleep statement in the synchronize block, so that other threads must wait for a thread to complete that synchronize block. So just add a long sleep statement inside your synchronize block and try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With