How many ways are there to create threads?

A question
comes from: https://cloud.tencent.com/developer/article/1684031

Not much to say, gold nine silver ten, many students will soon participate in the autumn recruitment. And multi-threading is definitely a must-question in interviews. Before opening, I ask everyone a question: How many ways are there to create threads?

Basic answer (wrong answer): two, inheriting Thread and implementing Runnable
advanced answer (wrong answer): multiple, inheriting Thread, implementing Runnable, thread pool creation, Callable creation, Timer creation, etc. I
believe that many students can do the above answers Answer it. But they are all wrong. In fact, there is only one way to create threads. why? Brother Dog, are you kidding me? Look horizontally and vertically, there are at least two kinds. Don't worry, put down the knife. Let me slowly analyze:

The first one: Inheriting Thread
first is to inherit Thread, the most classic method of creating threads, this method is very common. When I first started, I don't know how many times Gou had written it. It is written like this:

Guess you like

Origin blog.csdn.net/qq_41076577/article/details/108210510