Java highly concurrent processes and threads (two) the basic operation of threads

One, create a new thread

Creating a new thread is very simple. After initialization, you can enable the start() method.

Thread t1 = new Thread(); t1.start();

So what to do after thread start(). Thread also has a run() method, start will create a new thread to execute the run method.

t1.run(); The run method is executed in the current thread.

Note: Do not use the run method to start a new thread, it will only execute the code in the run() method serially in the current thread.

 

 

Guess you like

Origin blog.csdn.net/superiorpengFight/article/details/102798635