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