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.

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of David Gibbs
Sent: Thursday, May 07, 2009 11:20 AM
To: Java Programming on and around the iSeries / AS400
Subject: Thread waiting on a data queue ... doesn't respond to
interrupt()??

Folks:

Has anyone ever seen something like this?

I've got a thread that's listening on a data queue ... timeout value is
set to -1 (wait forever).

The thread is sent an interrupt message ... which should throw an
InterruptedException that I catch ... but sometimes it doesn't.

The code that is reading the data queue looks like this:

----------
int waitTime = -1;

try {
while(true) {
try {
DataQueueEntry entry = changeQueue.read(waitTime);
if (entry != null) {
processEntry(entry);
}
} catch (AS400SecurityException e) {
e.printStackTrace();
} catch (ErrorCompletingRequestException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalObjectTypeException e) {
e.printStackTrace();
} catch (ObjectDoesNotExistException e) {
e.printStackTrace();
}
}
} catch (InterruptedException e) {
System.out.println("Thread was interrupted, exit"); }
----------

The method that is trying to interrupt the thread is something like
this:

----------
monitorThread.interrupt();
try {
monitorThread.join();
} catch (InterruptedException e) {
logException(e);
}
----------

But it the join() method never seems to return.

I'm not 100% sure, but I think this has only been seen when the program
is running on the iSeries ... not on a PC.

Any thoughts?

Thanks!

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.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.