java multithreading: how to use threads

Threads are used in many situations in Java, and there are high concurrency in threads. How to use threads correctly? Let me share today, how to create and call a thread:

First of all, let's talk about the concept of thread. A thread is a task executed by a program, and a task is called a thread. For example, in my task manager, there are those that open the editor, some that open the webpage, etc., each of which can be called a thread, as shown in the figure:

There are four main ways to implement threads. Let me talk about the first one, which is to inherit Thread and rewrite the run() method. In order to verify whether this method is executed, for example, as shown in the figure.

Guess you like

Origin blog.csdn.net/weixin_47385625/article/details/111553096