This content has been marked as final. Show 2 replies
The ExecutorCompletionService has pretty much this exact example in the javadoc.
Few years ago I implemented a competition sorting algorithm: The idea was to use different sorting algorithms to sort the same array concurrently. All algorithms accessed concurrently a single array-instance at the same time. If one of sorting algorithms was finished then other algorithms were canceled.
I adapted few sorting algorithms like in place quick sort, insertion sort thus they could work on the same array without disturbing each other. To lock many variables at ones I used a scheduler which avoided deadlocks. Suddenly final sorting algorithm was very slow because the most of time was consumed by data-access and synchronization.
Here you can find the scheduler implementation:
Edited by: zarr on 31.05.2013 22:05