+ 2000000000000

Now that you've reminded me of java.awt.Toolkit.beep();  havoc will be made!

On Mon, Aug 17, 2009 at 8:47 PM, Michael Neale <[email protected]>wrote:

>
> The only sane way is this:
>
> try {
>
> .. your code here
>
> } catch (Throwable t) {
>   for (int i =0; i< 1000; i++)
>       java.awt.Toolkit.beep();
>   System.exit(-1);
> }
>
> Sometimes can use a Runtime.exec to delete the home directory for good
> measure, but that means platform specific code.
>
>
>
>
> On Aug 18, 8:58 am, Casper Bang <[email protected]> wrote:
> > For that we have Runtime().getRuntime().addShutdownHook() no? That's
> > what I used anyway with JSR-296, where Hans Muller had hardwired the
> > System.exit() call in the framework.
> >
> > /Casper
> >
> > On 17 Aug., 23:11, Peter Becker <[email protected]> wrote:
> >
> >
> >
> > > Jess Holle wrote:
> > > > Peter Becker wrote:
> >
> > > >> While I agree that you can have shared state, the scenario I had was
> a
> > > >> clean worker: some data goes in before the thread gets started,
> other
> > > >> data comes out at the end.
> >
> > > >> System.exit is a bad idea generally since you don't really know who
> is
> > > >> going to use your code in the future. If you call System.exit in
> your
> > > >> average Tomcat installation you'll probably take it down with you. I
> > > >> tend to restrict the System.exit calls to main(..) methods.
> >
> > > > Low-level code shouldn't be catching VirtualMachineError -- it should
> > > > always re-throw it.
> >
> > > I agree. But between the likelihood of this error being raised and the
> > > damage done if you catch it when you shouldn't the risk seems quite
> > > acceptable. Again: it is highly dependent on what your application is,
> I
> > > would certainly not recommend this for a mission or even life critical
> > > section of code.
> >
> > > > Only top-level thread handlers should catch these errors and call
> > > > System.exit().
> >
> > > And what happens to other threads? If you call System.exit you should
> > > have global knowledge of all application threads and their current
> > > state. Even in the presence of a VirtualMachineError it is probably
> > > better to try a clean shutdown. Calling System.exit could leave a lot
> of
> > > things in inconsistent state that will be hard to recover from. Are all
> > > your system's boundaries transactional?
> >
> > >   Peter
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to