Still sounds like a concurrency issue. When trying to coordinate
multiple threads, I tend to use a synchronizing object. The controlling
thread sets this object to a value to indicate it wants the other thread
to end, then does the join(). The controlled thread just checks this as
it goes around. In your example, though, the controlled thread might be
blocked waiting for the dataqueue. If it is waiting, you need to do
something to throw it off the block, which is what you're trying to do
with the Thread.interrupt(). Thread.interrupt(), however, won't always
cause a InterruptedException to be thrown in the controlled thread
depending on whether it is at a wait(), join() or neither. You probably
need to do both. The Thread.interrupt() will knock it off a wait, but
you need to check the synchonizing object (or maybe just the Interrupt
status) before reentering the wait.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of David Gibbs
Sent: Thursday, May 07, 2009 1:57 PM
To: Java Programming on and around the iSeries / AS400
Subject: Re: Thread waiting on a data queue ... doesn't respondto
interrupt()??
Dan Kimmel wrote:
You could have a race condition on a multiprocessor machine. The
dataqueue monitorThread is doing something in processEntry() when the
interrupting thread hits the join.
That's not something I specifically thought of ... but I don't think
it's the case.
This seems to happen (at least on this customers box) very consistently
... even when the application that's listening to the data queue is
doing nothing. The only time the processEntry() method would be invoked
is if there were an entry received from the data queue.
If the application were more active, I would say it's a possibility.
We had the customer move the application to a PC, instead of running it
on the iSeries, as a workaround ... and it seems to be working OK.
I've also sent them a patch that will change the data queue timeout from
-1 (forever) to 15 seconds. Also, instead of looping forever and hoping
for a InterruptedException, I'm controlling the loop based on the
thread's isInterrupted() method.
david
--
IBM i on Power - For when you can't afford to be out of business
--
This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.