Thread state
Summary:
-
Thread class inheritance
-
Subclasses inherit the Thread class with multithreading capabilities
-
Start thread: subclass object.start ()
-
Not recommended: Avoid OOP single inheritance limitations
-
-
Implement the Runnable interface
-
Implementation interface Runnable has multithreading capability
-
Start Thread: pass the target object +Thread object.start ()
-
Recommended use: Avoid the limitation of single inheritance, flexible and convenient, convenient to use the same object by multiple threads
-
// A resource
StartThread4 station = new StartThread4();
// Multiple proxies
new Thread(station,name:"Xiao Ming").start();
new Thread(station,name:"Teacher").start();
new Thread(station,name:"Little red").start();
Copy the code