Multi-threaded Learning Notes

Source: Internet
Author: User

1. Whichever way you use it, you end up relying on the thread class to start multithreading.

2. The start thread is calling the Start method instead of calling the Run method.

3. The same thread object cannot start 2 times, otherwise it will throw an exception: Java.lang.IllegalThreadStateException.

4. There is also a difference between the thread class and the Runnable interface in use, if a class inherits the thread class, it is not suitable for multiple threads to share the resources, and implements the Runnable interface, it can easily realize the sharing of resources.

5.

1 New MyThread (); 2 New Thread (My). Start (); 3 New Thread (My). Start (); 4 New Thread (My). Start ();

6.

1 New MyThread (); 2 New MyThread (); 3 New Thread (MT1). Start (); 4 New Thread (MT2). Start ();

7. Create ready-to-run blocking termination

8. When a thread calls the Stop () method or the run () method finishes executing, it is in a dead state. A thread that is in a dead state does not have the ability to continue running.

9. CurrentThread () is a static method of thread, and when you do not override this method of the parent class thread, there is no difference between this.currentthread and thread.currentthread at this time.

Ten. Thread-0

Java runtime, at least two threads are started, one is the main thread and the other is the garbage collection thread.

12. The main thread is likely to run out of other threads first.

Multi-threaded Learning Notes

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.