public class ThreadDemo1 { public static void main(String[] args) { MyThread myThread = new MyThread(); MyRunnable myRunable = new MyRunnable(); Thread thread = new Thread(myRunable); myThread.start(); thread.start(); } } class MyThread extends Thread{ @Override public void run() { System.out.println("MyThread.run()"); } @Override public synchronized void start() { System.out.println("MyThread.start()"); } } class MyRunnable implements Runnable{ @Override public void run() { System.out.println("MyRunnable.run()"); } public void start(){ System.out.println("MyRunnable.start()"); } }
print:
MyThread.start()
MyRunnable.run()