× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hi Thorbjørn

I don't have access to the code from home as I am just the tea boy :).

I'll email a full example tomorrow, but the basic gist of the code is as follows:

// Set up JDaemon, passing it this server and this thread
this.mJDaemon = new JDaemon(this, Thread.currentThread());
this.mDaemon = new Thread(this.mJDaemon);
/**
* Note this line is very important, its sets the Daemon thread to be a
* Daemon, meaning that it will close itself when all of the other
* threads are gone
*/
this.mDaemon.setDaemon(true);
this.mDaemon.start();

This is the constructor for the Daemon thread

public JDaemon(JServer server, Thread serverThread)
{
mServer = server;
mSpecificServerDataQue = mServer.getServerSpecific();
mServerThread = serverThread;
}


This is the code that Daemon calls when it wants to close down the server thread

this.mServer.setCloseDown(true);
this.mServerThread.interrupt();
closeDown = true;


meanwhile the Server is doing the following

while (!mCloseDown & !Thread.currentThread().isInterrupted()) {

testForAction();
}


inside test for action the server is sitting on a data queue

try {
System.out.println("Testing dq");
dqData = this.mServer.read(-1);

performAction(dqData);
} catch (InterruptedException ie) {
// It is OK to ignore this, as the interuption will cause
// mClosedDown to be set to true so no more
// testForAction() calls will be made
System.out.println("Server was interupted");
} catch (DynamicServiceInvokationException dsie) {
// TODO:Figure out what to do here
// New auditing feature
} catch (Exception e) {
// If there was an error here then the Server needs to close
e.printStackTrace();
System.out.println(e.getMessage());
this.mCloseDown = true;
}


As I have said in WDSC the InterruptedException is caught, and the server shuts down, on the i5 it appears the InterruptedException is not thrown and the Server says alive on DEQW sitting on the Data queue


---- Original message ----
Date: Thu, 13 Nov 2008 21:20:09 +0100
From: java400-l-bounces@xxxxxxxxxxxx (on behalf of Thorbjørn Ravn Andersen <ravn@xxxxxxxxxx>)
Subject: Re: Threads problem in Java on i5
To: Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx>

Walden H. Leverich skrev:
Thread behaviour are notoriously platform dependent, and you switch platform.


But, but.... it's Java, it should work anywhere.... :-) Seriously though, if the JVM doesn't abstract you from something as simple as that there's a problem there.

Thread behaviour is notoriously vaguely described in the JVM spec.
This might very well be badly written but happen to work on Windows due
to something else (the Windows scheduler being different, being run on
two cores on the PC and one on the i).

The simplest way is to see the code exhibiting the behaviour.
--
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.