Four ways to achieve multi-threaded

1, inheritance Thread class, override the run method

2, implement Runnable interface, the interface to change the method run

3, to achieve callable interface call override method

4, create a thread by thread pool

Two kinds of the foregoing may be attributed to a Class: None Return Value simple reason that, by rewriting the run method, the return value is run void embodiment, there is no way to return result

The latter two into one group: returns a value, through the callable interface to achieve call method, the return value is Object, it returns the result in the object in the Object

https://blog.csdn.net/u011480603/article/details/75332435

Guess you like

Origin www.cnblogs.com/9797ch/p/11539679.html