當前位置:編程學習大全網 - 編程軟體 - 在線高分求助JAVA多線程編程題 (極為簡單的多線程顯示字符)

在線高分求助JAVA多線程編程題 (極為簡單的多線程顯示字符)

public class Demo {

public static void main(String[] args) {

new Demo().start();

}

public void start() {

Thread A = new Thread(new Runnable() {

public void run() {

while(true) {

System.out.println("A");

try {

Thread.sleep(500);

}

catch(InterruptedException e) {}

}

}

});

Thread B = new Thread(new Runnable() {

public void run() {

while(true) {

System.out.println("B");

try {

Thread.sleep(2000);

}

catch(InterruptedException e) {}

}

}

});

A.start();

B.start();

}

}

//已經編譯運行過了 over ^_^

  • 上一篇:標準ASCII碼用7位二進制位表示壹個字符的編碼那麽ASCII碼字集***有幾個不同的字符
  • 下一篇:“水仙花數”C語言程序
  • copyright 2024編程學習大全網