Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

interrup()  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I do nt understand how does interrupt() mehtod work in JAVA,

May someone give me example by code?
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A thread, T1, is able to "interrupt" another thread, T2, by calling the interrupt() method on T2's thread object. Interruption can lead to different scenarios depending on the state of T2 while being interrupted.

Read the javadoc for what interrupt does
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#interrupt()

If you want to interrupt a thread, make sure the thread knows how to handle interruption correctly.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi abalfazl,

Sorry for being pedantic here; but please - at minimum - try to spell the method correctly. If you can get it right in the body, it shouldn't be that
hard to pay the same attention to the subject line.

As software developers, we all know that compilers do not subscribe to
the adage: "Be liberal in what you accept ...".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!