Namely, could it ever be the case that a task is submitted and gets completed before the next task is submitted? (Lines 58, 59) If this were the case, then a deadlock might potentially not happen for this particular example, correct?
I understand the the purpose of the Thread.sleep(100) line is to give other threads a chance to do some work. But I'm asking the question, "could it ever be the case that there might not be another thread available?" I know that 10 threads are allocated for this pool, so I guess my main confusion regards how can I be absolutely sure that a deadlock will occur here? Ancillary confusion has to do with things like understanding whether or not the order of submit() calls matter, and when exactly the pool gets populated with tasks.
Note: this comes from the OCP book in the chapter on concurrency - specifically, the "Identifying Threading Problems" section.