编写java程序 编写三个线程,一个线程输出a~z,一个线程输出A~Z,一个线程输出1~26。
时间: 2024-05-08 12:16:08 浏览: 61
```
public class PrintThread extends Thread {
private final int start;
private final int end;
public PrintThread(int start, int end) {
this.start = start;
this.end = end;
}
@Override
public void run() {
for (int i = start; i <= end; i++) {
System.out.print((char) (i + 'A' - 1));
}
}
}
public class Main {
public static void main(String[] args) {
PrintThread thread1 = new PrintThread(1, 26);
PrintThread thread2 = new PrintThread(27, 52);
PrintThread thread3 = new PrintThread(65, 90);
thread1.start();
thread2.start();
thread3.start();
}
}
```
阅读全文