What is the difference between interrupt() and join() in threads?Give an example program?

Showing Answers 1 - 3 of 3 Answers

jeyaganesh

  • Nov 22nd, 2005
 

Answertinterrupt() throw an interrupt if the thread is blocked.join() waits for a thread to terminate

  Was this answer useful?  Yes

abhishek

  • Dec 5th, 2005
 

Interupt is the method on the thread to distrub or interupt on the other thread which are under execution.

Where as the join method is used to say t.join() is to suspend the current thread operation for a time being and go to the other thread and return back after completing the other task.

t.join();

t.join(200);//here the current thread is suspended for a 200msec,with in this time u have to return back after completing the task.

  Was this answer useful?  Yes

Surya Narayan Choudhury

  • Jan 26th, 2006
 

In fact when interupt() is called it set's a flag in the thread class, which can be further checked in the run() method by using isInterupted() meth. Where as join() let the current thread to wait until the thread object on which it called is terminated.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions