Ext.: http://blog.csdn.net/wwww1988600/article/details/7309070
There are two ways to implement multithreading in Java, one is to inherit the thread class, one to implement the Runnable interface, and the thread class to be defined in the Java.lang package. A class that inherits the thread class to overwrite the run () method in this class can implement multithreaded operations, but only one parent class can inherit from a class, which is the limitation of this method.
The difference between the two ways of implementation and contact:
In the program development, as long as the multithreading is always to achieve runnable interface-based, because the implementation of runnable interface compared to
Inheriting the thread class has the following benefits:
To avoid the limitations of point inheritance, a class can inherit multiple interfaces.
--Suitable for resource sharing ( this is wrong )
explanation: In Java, in order to realize the sharing of resources, we need to use the semaphore mechanism, there are two ways: 1, using semaphore 2, using Synchronize
The concrete example will not move.
Differences between thread and runnable in Java