//通过继承Thread实现多线程
import java.util.concurrent.locks.*;
class MyThread extends Thread
{
public void run()
{
System.out.println("my thread is running");
}
}
class test
{
public static void main(String[] args)
{
MyThread thread = new MyThread();
thread.start();
}
}
//通过实现Runnable接口实现多线程
import java.util.concurrent.locks.*;
class MyTask implements Runnable
{
public void run()
{
System.out.println("my thread is running");
}
}
class test
{
public static void main(String[] args)
{
MyTask task = new MyTask();
Thread thread = new Thread(task);
thread.start();
}
}
//通过继承Thread实现多线程import java.util.concurrent.locks.*;class MyThread extends Thread{ public void run() { System.out.println("my thread is running"); }}class test { public static void main