Best Practice For Forcing A Thread To Unblock Itself



Hi All,

I have a feeling I'm asking for a pig to smell like a rose, but...

I have what is surely a very common problem in multi-threadead
applications:

Thread B is blocked waiting for something to happen, and Thread A,
located in the same process as B, wants B to stop what ever it is doing
and exit gracefully so that the application can shut down properly.
Thread A then waits on the handle of B to determine when thread B has
exited.

Assuming that thread B likes to block itself indefinitely waiting on
whatever it is waiting on, what is the best practice for having A tell
B to stop?

Currently, the only thing I can think of is to let go of the option
that thread B can block indefinitely, forcing it to periodically check
an event signaled by A to determine if it needs to stop. I never
really liked this model because if there are, say, 9 threads, I would
have to estimate on a thread-by-thread basis the optimal time-out on
thread B's wait duration. Very tedious and guaranteed to be incorrect
(if I do it).

Is there anything better?

-Le Chaud Lapin-

.



Relevant Pages

  • Re: Workstation CPU choice
    ... even tradeoff between the threaded and unthreaded applications, ... I'm waiting for a few more Yorkfields (Quad Core 45nm) to come on the market. ... The 45nm parts run cooler than the 65nm parts and there are comments on Newegg about running the 8400 at 4GHz although most people are reporting 3.6GHz. ...
    (comp.sys.intel)
  • Re: Workstation CPU choice
    ... even tradeoff between the threaded and unthreaded applications, ... I'm waiting for a few more Yorkfields (Quad Core 45nm) to come on the ... Newegg about running the 8400 at 4GHz although most people are reporting ...
    (comp.sys.intel)
  • Re: Apple screws up Security Update 2005-007 (Tiger only)
    ... >> Apple breaks 64-bit applications with the latest security update... ... >> probably best be served by waiting for the update that must be coming..." ...
    (uk.comp.sys.mac)
  • Re: VAST 5.5.2 wsock32.dll
    ... applications is based on WINSOCK.DLL. ... The APIs provided are identical except that the 32-bit ... 100% CPU usage. ... waiting with a Delay, so as not to use a lot of CPU time. ...
    (comp.lang.smalltalk)
  • Re: screen saver for auto log off after a certain period of idle time
    ... I will be using this configuration for a system that has this ... requirements and other applications are not important. ... >> b) Clients are Windows XP clients ... > If you are waiting for the application to finish to log me off, ...
    (microsoft.public.windowsxp.security_admin)

Loading