The difference between Thread and Runnable in Java: threadrunnable
Turn: http://blog.csdn.net/wwww1988600/article/details/7309070
In java, You can implement multithreading in two ways. One is to inherit the Thread class, the other is to implement the Runnable interface, and the Thread class is defined in the java. lang package. As long as a class inherits the Thread class and overwrites the run () method in this class, it can implement multi-threaded operations. However, a class can only inherit one parent class, which is the limitation of this method.
Differences and links between the two implementation methods:
In program development, as long as it is multi-thread, it will always be dominated by the implementation of the Runnable interface, because the implementation of the Runnable interface is
Inheriting the Thread class has the following benefits:
-> Avoid the limitations of point inheritance. A class can inherit multiple interfaces.
-> Suitable for Resource Sharing (this is incorrect)
Explanation: in java, to share resources, you must use the Semaphore mechanism. There are two methods: 1. Use Semaphore 2 and use Synchronize.
The specific example will not be moved.