This sample application implements merge sort algorithm using multiple threads.
The algorithm for parallel merge sort was taken from the Merge Sort example available online from the University of Washington
The original example uses threads directly. This sample application uses an ExecutorService
to run threads.
This application runs continuously and prints an interval summary statistics of algorithm run time for multiple random number arrays. The application will also print final summary statistics of algorithm run time at the program exit.
The application will throw Out of Memory error after some time when you run following command
java -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=settings=profile,duration=2m,name=ThreadLeak,filename=threadleak.jfr -XX:FlightRecorderOptions=loglevel=info -jar target/threadleak.jar
In Threads -> Overview tab, you should see thread count is increasing steadily.
Run the application with --stop-leakage
parameter, which will use a single ExecutorService
throughout the
application.