两个线程共用一个代码逻辑,RunnableTask可以继承其它类。
public class RunableTask implements Runnable
{
public static void main(String[] args) throws InterruptedException
{
RunableTask task = new RunableTask();
new Thread(task).start();
new Thread(task).start();
}
@Override
public void run()
{
System.out.print("实现Runnable接口的run方法方式");
}
}