NodeManager Source Reading Thread.setdefaultuncaughtexceptionhandler

Source: Internet
Author: User
Tags static class
NodeManager Source

Read the NodeManager source of the time to notice a very interesting Java code, as follows

  public static void Main (string[] args) throws IOException {
    Thread.setdefaultuncaughtexceptionhandler (new Yarnuncaughtexceptionhandler ());
    Stringutils.startupshutdownmessage (Nodemanager.class, args, LOG);
    NodeManager NodeManager = new NodeManager ();
    Configuration conf = new yarnconfiguration ();
    New Genericoptionsparser (conf, args);
    Nodemanager.initandstartnodemanager (conf, false);
  
Test

The following test comes from confirming whether the scenario will take effect under the multithreaded submission task. Because another article inside said executorservice.submit the scene does not take effect. But in fact it can still be effective.
Article referred to: http://blog.csdn.net/u013256816/article/details/50417822

public class Mydefaultuncaughtexceptionhandler {static Class Myuncauthexceptionhandler Impl
            Ements thread.uncaughtexceptionhandler{@Override public void uncaughtexception (Thread t, Throwable e) {
        System.out.println ("uncaughtexception:" + t.getname () + "" + e.getmessage ()); } public static void Main (String args[]) {Thread.setdefaultuncaughtexceptionhandler (new myuncauthexcept
        Ionhandler ());
        Executorservice es = Executors.newcachedthreadpool ();
            Es.execute (New Runnable () {@Override public void run () {int i = 2/0;
        }
        });
    Es.shutdown (); }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.