That makes sense and agrees with what I was saying. DEQW is not a java
wait() and therefore Thead.interrupt() is not going to throw an
exception in the controlled thread.
If this were a purely i5OS ILE program, the only way to knock the
process off the DEQW would be to have the other thread write something
to the data queue. That data queue entry would tell the thread sitting
on the data queue to end. You could do the same in your java app. The
controlling thread writes a dataqueue entry that the controlled thread
reads off the dataqueue telling it to end. Pretty simple and it'll work
native or non.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Neill Harper
Sent: Thursday, January 15, 2009 3:25 PM
To: 'Java Programming on and around the iSeries / AS400'
Subject: RE: Thread waiting on a data queue ... doesn't respond
tointerrupt()??
David
I asked this a few months ago and had to get an answer from the guys who
run JTOpen, they told me that when using the native toolbox the
interrupt basically doesn't work as there is no way for a java thread to
interrupt a DEQW operation.
The solution was to set the AS400 connection object to mustusesockets
and force the dataqueue operations throught the dataq server
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx]
On Behalf Of David Gibbs
Sent: 07 May 2009 17:20
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.
--
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.