Java Thread类的start( )和run( )区别

让一个类继承Thread,重写run()方法,然后调用时使用:new ThreadImp().start()方法
来启动该类的实例!不要用new ThreadImp().run() !!!

root cause:
>> the start() method call run() method asynchronously (does not wait for any result, just fire up an action),
>> while we run run() method synchronously - we wait when it quits and only then we can run the next line of our code.

 

你可能感兴趣的:(java,thread,UP)