我知道在Java线程中它implements Runnable
是首选的,extends Thread
因为它允许我们在需要时扩展其他一些类。但是,如果是这样的话,它extends Thread
也具有自己的implements Runnable
优势吗?如果是,这些优势是什么?
因为有时(几乎从不,但是有时)您希望能够更改的基本行为Thread
。
那是您需要扩展它的时候。
您可以通过重写Thread
类中的方法来更改它,而不能通过实现中的方法来更改它Runnable
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句