So we have a task to sort an array using semaphores in Java. The task is pretty easy and I've solved it in nearly couple of minutes but for the last part- merging.
Our task was to divide the given array into two, sort the parts simultaneously (using semaphores) and then merge again (using semaphores).
My question is, what is the purpose of merging it using more than one Thread as while filling the final array each of them have to constantly wait for each other, since only one can push elements to the array at one time?
Or am I missing something? Thanks.