|
matters,
Hi James,
Your Timer invocation looks OK. The other thing that (always)
aside from the interval frequency, is what the thread is actually doing;run?
that is, how intensive is and how long does DirectoryMonitorNotifier()
does
Clearly it's doing disk accesses, which are relatively slow. What
the constructor do, since you're creating a new one every time. Justbe
thread
frequency shouldn't account for 120% (interesting number) and 11 % of CPU
respectively. One of my favorite stories, although it doesn't involve
Timers or threads, has to do with a client running a third party package
that provided them with *18 hour* End of *Day* processing. Think about
that. Things got a lot better after we did a softwarectomy.
Another option, if the constructor is intense, is to use the same
DirectoryMonitorNotifier with its own yield/sleep thread(s).
I have Timers for several operations at various clients (happens that
none of them, so far, are AS/400 boxes ) and haven't seen problems.
However, typical frequencies are 5 - 10 minutes.
Joe Sam
Joe Sam Shirah - http://www.conceptgo.com
conceptGO - Consulting/Development/Outsourcing
Java Filter Forum: http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International? http://www.jguru.com/faq/I18N
Que Java400? http://www.jguru.com/faq/Java400
----- Original Message -----
From: "James Perkins" <jrperkinsjr@xxxxxxxxx>
To: "Java Programming on and around the iSeries / AS400"
<java400-l@xxxxxxxxxxxx>
Sent: Thursday, August 21, 2008 2:06 PM
Subject: Re: Never Ending Java Program
Thorbjørn,
I'm using a TimerTask, so in the code I don't yield or sleep.
Here is what the constructor looks like.
public DirectoryMonitor(long interval) {
files_ = new HashMap();
dirs_ = new HashMap();
listeners_ = new ArrayList();
timer_ = new Timer(true);
timer_.schedule(new DirectoryMonitorNotifier(), 0, interval);
}
I got most of the code from some where, can't remember exactly. It might
work re-working to implement Runnable and use Observer and Observable toIn
notify. I've never used TimerTask before so I don't know much about it.
--
Thanks,
James R. Perkins
On Thu, Aug 21, 2008 at 9:30 AM, Thorbjørn Ravn Andersen <
thunderaxiom@xxxxxxxxx> wrote:
James Perkins skrev den 21-08-2008 17:27
I have ran it interactively and it was using about 120% of the CPU.
(JAVA400-L)batch(JAVA400-L)
it was around 11%.How often do you run Thread.yield() and Thread.sleep() ?
--
Thorbjørn Ravn Andersen "... plus... Tubular Bells!"
--
This is the Java Programming on and around the iSeries / AS400
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
mailing list(JAVA400-L)
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
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 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.