> I wrote a java application that runs through several steps including
> retrieving some records from a database and posting them to an application
[quoted text clipped - 9 lines]
> Question: Do I need to put in some type of trap or handler so that a user
> can kill an application?
Might not be a bad idea. If your application has some sort of GUI, you
could add a cancel button so that the user can stop the application from
doing whatever it's doing.
> Is that what InterruptedException is for?
I doubt that killing the java.exe process in the Task Manager will
translate into an Exception getting thrown in your Java program.
> One person suggested putting Thread.Sleep(100) periodically in the loop --
> so that a termination gets a chance to be read.
>
> Is that right?
>
> It seems really wasteful....
If you're periodically sleeping merely to give other threads a chance,
you might want to use Thread.yield() instead. On most implementations, if no
other threads are waiting to run, Thread.yield() will immediately return and
your program will keep running. Otherwise, your thread will pause while the
other thread does its work.
- Oliver
>One person suggested putting Thread.Sleep(100) periodically in the loop
>-- so that a termination gets a chance to be read.
If the java.exe is so far up its a.s that you can't even kill it with
the taskmanager very unlikely any internal code will respond either.
This is a bug in the OS. No task should be able to do that even
intentionally.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.