• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Scheduling an interrupt on a borrowed thread

 
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The authors of "Threads In Practice" have quoted:

If the task completes before the timeout, the cancellation task that interrupts the thread in which timedRun was called could go off after timedRun has returned to its caller



given the TimedRun code below-



Further, if the task is not responsive to interruption,timedRun will not return until the task finishes, which may be long after the desired timeout(or even not at all). A timed run service that doesn't return after the specified time is likely to be irritating to its callers.



can anyone explain what actually they meant to say?
 
praveen kumaar
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually i have posted a question about 7 hours ago but till now i have not get any solution.so i worked myself on this.

i found it in a sense(I don't know whether author is intending to mention the same or
not,thats why i am posting here in order to let me know whether am i correct or not ? )

the problem with the code seems like this-suppose the time at which executor thread interrupt the
taskthread may be at that time run method of "r" has not completed causing invalid termination of
taskthread (before successful execution) consequently giving the inconsistent results or another sitution is
when the taskthread is not responsive to interruption causing taskthread to run for a long time
resulting in breaking the policy of timedRun.

correct me if i am wrong.

reply will be appreciated.

thanks.

regards
praveen
 
author
Posts: 23951
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
Hmmm... I am not exactly sure why you felt that creating a new topic was preferred, than to simply following up ... regardless, I have merged your topics together. Hopefully, this will keep the discussion together in one place.

Henry
 
Henry Wong
author
Posts: 23951
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

praveen kumaar wrote:

Further, if the task is not responsive to interruption,timedRun will not return until the task finishes, which may be long after the desired timeout(or even not at all). A timed run service that doesn't return after the specified time is likely to be irritating to its callers.



can anyone explain what actually they meant to say?



Well, as you may have noticed, communications between threads is mostly cooperative. This also includes interrupts. It is possible for a thread to be doing stuff that isn't interruptable. It is possible for a thread to not check the interrupt status. It is possible for a thread to not handle the case of being interrupted, and mess everything up. I believe the first few, which may cause the thread to go pass its desired timeout, is what the author was referring to.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic