P
Paul Tomblin
I have a daemon program that listens for "events", and each time I get one
I spawn off a thread to process it. I've had a couple of occasions where
one of these threads gets "stuck", and because it uses a synchronization
object, the threads behind it get stuck as well until they restart the
daemon.
(I spawn threads rather than doing them one at a time so that I can return
to the event listener immediately.)
I'm at my wits end trying to figure out where it could possibly be getting
stuck, since it's extremely rare and has never happened in my lab. I've
added tons of debug, but of course I haven't seen it since then except at
customer sites that didn't keep the log files. So I though I'd implement
a job monitor, which does a join(MAX_RESPONSE_TIME) on a running thread,
and if the thread still isAlive(), I set a flag on it, and send it an
interrupt(), then do a join() to wait for it to finish. (The thread
periodically checks if that flag is set and exits quickly if it's set.)
At that point, I try to restart it by calling the thread's start() method,
but it never seems to start. How can I restart a thread?
I spawn off a thread to process it. I've had a couple of occasions where
one of these threads gets "stuck", and because it uses a synchronization
object, the threads behind it get stuck as well until they restart the
daemon.
(I spawn threads rather than doing them one at a time so that I can return
to the event listener immediately.)
I'm at my wits end trying to figure out where it could possibly be getting
stuck, since it's extremely rare and has never happened in my lab. I've
added tons of debug, but of course I haven't seen it since then except at
customer sites that didn't keep the log files. So I though I'd implement
a job monitor, which does a join(MAX_RESPONSE_TIME) on a running thread,
and if the thread still isAlive(), I set a flag on it, and send it an
interrupt(), then do a join() to wait for it to finish. (The thread
periodically checks if that flag is set and exits quickly if it's set.)
At that point, I try to restart it by calling the thread's start() method,
but it never seems to start. How can I restart a thread?