package test;
/**
* 创建线程
*
*/
public class Demo1 {
public static void main(String arg[]){
MyThread t=new MyThread();
t.start();
myRunnable r=new myRunnable();
Thread run=new Thread(r);
run.start();
}
}
/**
*
* 继承Thread类
*
*/
class MyThread extends Thread{
@Override
public void run() {
System.out.println("Thread线程:"+Thread.currentThread().getId()+"正在运行");
}
}
/**
* 实现Runnable接口
*
*/
class myRunnable implements Runnable{
@Override
public void run() {
System.out.println("Runnable线程"+Thread.currentThread().getId()+"正在运行");
}
}
/**
* 创建线程
*
*/
public class Demo1 {
public static void main(String arg[]){
MyThread t=new MyThread();
t.start();
myRunnable r=new myRunnable();
Thread run=new Thread(r);
run.start();
}
}
/**
*
* 继承Thread类
*
*/
class MyThread extends Thread{
@Override
public void run() {
System.out.println("Thread线程:"+Thread.currentThread().getId()+"正在运行");
}
}
/**
* 实现Runnable接口
*
*/
class myRunnable implements Runnable{
@Override
public void run() {
System.out.println("Runnable线程"+Thread.currentThread().getId()+"正在运行");
}
}