Kotlin, Kotlin Coroutines, Android, Concurrency, Multithreading.
permit is available. As P4 and P2 complete and release the lock from Semaphore (P1 and P3 still running). 2 permits become available in the semaphore, and thus P5 and P6 acquire a permit to execute. By the time, P1 and P3 also complete and release semaphore permit. After completion of P5 and P6,