• Post Reply Bookmark Topic Watch Topic
  • New Topic

Impact of interrupt on Running thread?

 
scott miles
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if a thread T1 is running and interrupt is called on this thread,there will be no impact on T1. To handle this
we have to call if (Thread.interrupted()) inside run method right?

Interrupt will have impact when thread is under wait,sleep or join(or methods that throw InterruptedException). Right?
 
Paul Clapham
Sheriff
Posts: 21867
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
scott miles wrote:if a thread T1 is running and interrupt is called on this thread,there will be no impact on T1. To handle this
we have to call if (Thread.interrupted()) inside run method right?

Interrupt will have impact when thread is under wait,sleep or join(or methods that throw InterruptedException). Right?


No. The API documentation goes into great detail about what happens when you call a thread's interrupt() method. However the documentation doesn't use the word "impact" and you do. We could debate whether setting the thread's interrupt status constitutes an "impact", but it would be more practical for you to see what the documentation says.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!