PrepZone Logo
PrepZone
Back to Java

Java · Medium

What is Thread.interrupt()? How do you correctly handle interruption in long-running tasks?

JavaConcurrency

Answer preview

Thread.interrupt() sets the thread's interrupted status flag. It does not stop the thread — it signals the thread should stop what it's doing and clean up.…