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

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

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:
    719
    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:
    469
    Martin Dechev
    Apr 6, 2004
  3. Simon Harvey

    A thread safety question

    Simon Harvey, Aug 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    543
    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:
    475
    Scott Allen
    Dec 10, 2004
  5. =?Utf-8?B?RGlmZmlkZW50?=

    Thread-safety and Singleton methods

    =?Utf-8?B?RGlmZmlkZW50?=, Jan 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    690
    Karl Seguin
    Jan 13, 2005
  6. =?Utf-8?B?RmVuZw==?=

    Thread safety issue

    =?Utf-8?B?RmVuZw==?=, Jun 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    546
    Bruce Barker
    Jun 16, 2005
  7. =?Utf-8?B?U2ltbw==?=

    ASP.net and thread safety

    =?Utf-8?B?U2ltbw==?=, Jan 13, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    802
    =?Utf-8?B?U0VC?=
    Jan 13, 2006
  8. Barney Barumba
    Replies:
    0
    Views:
    759
    Barney Barumba
    Jul 23, 2003
Loading...