Best Practice For Forcing A Thread To Unblock Itself
- From: "Le Chaud Lapin" <unoriginal_username@xxxxxxxxx>
- Date: 1 Nov 2005 12:13:02 -0800
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-
.
- Follow-Ups:
- Re: Best Practice For Forcing A Thread To Unblock Itself
- From: Jochen Kalmbach [MVP]
- Re: Best Practice For Forcing A Thread To Unblock Itself
- Prev by Date: Re: passing username/passwd between two processes securely...
- Next by Date: Re: Best Practice For Forcing A Thread To Unblock Itself
- Previous by thread: passing username/passwd between two processes securely...
- Next by thread: Re: Best Practice For Forcing A Thread To Unblock Itself
- Index(es):
Relevant Pages
|
Loading