使用线程与可运行

时间:2019-11-04 09:15:29

标签: java multithreading threadpool runnable

MyThread extends Thread implement MyInterface

我需要以单独的线程(MyThread().start())或在线程工具中执行以上类。

问题是,我可以使用线程池中定义的以上类MyThread吗?

threadPool = new ThreadPoolExecutor(5, 70, 1600, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
threadPool.execute(new MyThread());

如果两者之间存在差异:

MyThread extends Thread implements MyInterface

MyThread implements Runnable, MyInterface

在线程池中执行时。

0 个答案:

没有答案