public class test1{ public static void main(String[] args) { //查看三个线程运行情况 MyThread mt = new MyThread(); mt.start(); MyThread1 mt1 = new MyThread1(); mt1.start(); MyThread2 mt2 = new MyThread2(); mt2.start(); } } class MyThread extends Thread{//内部类方式 @Override public void run() { while(true) { System.out.println("11"); try { Thread.sleep(1000 * 10);// 每10秒向数据同步一次 } catch (InterruptedException e) { e.printStackTrace(); } } } } class MyThread1 extends Thread{ @Override public void run() { while(true) { System.out.println("22"); try { Thread.sleep(1000 * 5);// 每10秒向数据同步一次 } catch (InterruptedException e) { e.printStackTrace(); } } } } class MyThread2 extends Thread{ @Override public void run() { while(true) { System.out.println("33"); } } }