user836026
user836026

Reputation: 11340

Does it harm if I send many interrupt to non-sleeping Thread

I have a thread that I make it sleep (using Thread.sleep(60000) ) for some time when waiting for some task to execute. Once there a request arrived, I wake it up from another thread by calling (t.inerrupt).

I can see it it works fine so far. If I send t.inerrupt when Thread in a sleep, it wake up. However, what if the process is not sleeping (doing actual work), would calling t.inerrupt have any effect on the thread?

Upvotes: 0

Views: 54

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279870

Read the javadoc

If none of the previous conditions hold [ie. thread is not blocked or sleeping] then this thread's interrupt status will be set.

So only a flag is set.

Upvotes: 2

Related Questions