In Java, I know that the default thread priority is 5. I have a class which basically sleeps for n number of seconds while doing other stuff on the side. If I create 20 threads in random order, each with that class as the target with n being either 10 or 20 seconds, how is it that all the 10 second ones finish first, and then the 20 second ones finish.
What I thought would happen was that since I am running a dual core processor, only 2 threads can run actually simultaneously. Therefore, the scheduler would pick 2 threads arbitrarily, since they are all the same priority, and run them first, which means that sometimes a 20 second thread will have to run before a 10 second one and so on and so forth.