14 Thread Properties

Source: Internet
Author: User

 Packagethread; Public classTestthree {/**     * Thread Properties: * Thread priority, daemon thread, thread group, unhandled exception processor * * * Thread priority * public static final int min_priority = 1; Minimum priority * public static final int norm_priority = 5; Default priority * public static final int max_priority = 10;//Maximum priority * * public static native void yield (); The current thread withdraws, and if other threads have the same priority as this thread, those threads will be dispatched * * * Daemon thread * Public final void Setdaemon (Boolean arg0) {} * in     A thread is set up to be a daemon thread before it is started, service to other threads, and the virtual machine exits when there is only a daemon thread left. * Daemon threads should not access intrinsic resources, such as files, databases.     It will be interrupted at any time, even in the middle of an operation. * * * Replacement processor can use the log API to send reports of uncaught exceptions to log files *//Set an exception handler for all threads * public static void S Etdefaultuncaughtexceptionhandler (Uncaughtexceptionhandler arg) {} * * *//Set gets uncaught exception handler, the thread group object is treated as   * public static Uncaughtexceptionhandler Getdefaultuncaughtexceptionhandler () {} * * * * *     When a thread terminates due to an uncaught exception, the customer report is required to be recorded in the log. *//parameter: Thread e uncaught exception object * void Uncaughtexception (thread T, T, terminated due to uncaught exception)Hrowable e) * * *          */             Public Static voidMain (string[] args) {Thread T1=Thread.CurrentThread ();         T1.yield (); T1.setdaemon (true);        T1.getuncaughtexceptionhandler ();                            Thread.setdefaultuncaughtexceptionhandler (Thread.getdefaultuncaughtexceptionhandler ()); }}

14 Thread Properties

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.