• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

interrupt

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

WHY in the following dode,thread does not exits ,when we call interrupt on it?

 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lakshmi amulya:
Hi,

WHY in the following dode,thread does not exits ,when we call interrupt on it?



When you interrupt a thread... if the thread is executing wait(), sleep(), or join(), an InterruptedException will be thrown. For I/O operations, with some JVMs, you will get an IOException. For everything else, an interrupted flag will be set so that the thread can check it.

In your case, all your thread does is spin on the while loop. It's not executing anything that can generate an exception, and it's not check the flag to see if it has been interrupted.

Henry
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic