Process the list of threads depending on their state: 1. If the thread isn't running yet, then start it. 2. If the thread is waiting, then interrupt it. 3. If the thread is running, check the isInterrupted flag. 4. If the thread has stopped running, then display its priority on the console.
A switch for threads
You must be signed in to leave a comment
18 January 2022, 14:56
Bug in validation that has to be addressed: When you do the isInterrupted() check... if you print the result, it will fail validation for the next condition in the list of tasks. So you'll be looking for errors for the TERMINATED state when the error is actually in the RUNNABLE state.
2 November 2021, 10:55
Condition 2 should say: If the thread is non-Runnable, interrupt it.