thread safety - using deprecated stuff Bloches example.

Discussion in 'Java' started by puzzlecracker, Jan 30, 2006.

  1. public static void sneakyThrow(Throwable t){
    Thread.currentThread().stop(t);
    }

    ----It appears that you can throw exception from any point in your
    code.
    what does it mean?

    How and why it bypasses all the exceptions? bypassed where?

    it is item 43 in Java Puzzlers.

    I am not quite sure what it means.

    Can someone elaborate....
     
    puzzlecracker, Jan 30, 2006
    #1
    1. Advertising

  2. puzzlecracker wrote:
    > public static void sneakyThrow(Throwable t){
    > Thread.currentThread().stop(t);
    > }
    >
    > ----It appears that you can throw exception from any point in your
    > code.
    > what does it mean?
    >
    > How and why it bypasses all the exceptions? bypassed where?


    Exceptions aren't bypassed, but exception checking is.

    For a method (in source code) to be able to throw an exception that does
    not extend Error or RuntimeException, a throws clause needs to be
    present. The checking is done at compile-time, not at runtime. There are
    a number of ways to throw a checked exception from methods that do not
    declare that exception, as detailed in the book.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
     
    Thomas Hawtin, Jan 30, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hans

    What is thread safety?

    Hans, Oct 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    604
    Sahil Malik
    Oct 12, 2004
  2. George Ter-Saakov

    LiteralControl thread safety.

    George Ter-Saakov, Apr 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    351
    Martin Dechev
    Apr 6, 2004
  3. Simon Harvey

    A thread safety question

    Simon Harvey, Aug 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    420
    Alvin Bruney [MVP]
    Aug 6, 2004
  4. thechaosengine

    Thread safety when subclassing the Page class

    thechaosengine, Dec 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    412
    Scott Allen
    Dec 10, 2004
  5. Barney Barumba
    Replies:
    0
    Views:
    579
    Barney Barumba
    Jul 23, 2003
Loading...

Share This Page