×

Good News Everybody!

A new search engine is coming soon.

As a stop gap measure, we are using Google's custom search engine service.





Hi James,

Your Timer invocation looks OK. The other thing that (always) matters,
aside from the interval frequency, is what the thread is actually doing;
that is, how intensive is and how long does DirectoryMonitorNotifier() run?

Clearly it's doing disk accesses, which are relatively slow. What does
the constructor do, since you're creating a new one every time. Just 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 be
work re-working to implement Runnable and use Observer and Observable to
notify. I've never used TimerTask before so I don't know much about it.


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-2026 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.