I have a program with multiple threads operating on a single instance of a class. Sometimes one of these threads will get interrupted. I have in the method header "throws InterruptedException" so it does that part correctly. The problem is that when a thread gets interrupted, the fields don't get reset, so the next thread that comes in gets all messed up.
How do I check if a thread is interrupted so that I can reset the variables for the next thread that comes in? I'm not sure where to address this in my code. I have tried something like:
if(Thread.currentThread().isInterrupted()) {
//reset variables here
}
or:
if(Thread.interrupted()) {
//reset variables here
}
Can anyone help me out? Thank you in advance!