public class test01 {
public static void main(String[] args) throws InterruptedException {
// 初始化
Object o = new Object();
Object obj = new Object();
char[] word = new char[36];
for (int i = 0; i < 26; i++) {
word[i] = (char) ('a' + i);
}
for (int i = 0, j = 26; i < 10; i++) {
word[j++] = (char) ('0' + i);
}
long begin = System.currentTimeMillis();
char[] total;
total = new char[1];
for (int i = 0; i <= 35; i++) {
// 第一个字母
total[0] = word[i];
Thread thread1 = new Thread(() -> {
char[] t1 = new char[2];
copy(total,t1);
for (int j = 0; j <= 35; j++) {
// 第二个字母
t1[1] = word[j];
Thread thread2 = new Thread(() -> {
// 第三个字母
char[] t2 = new char[3];
copy(t1,t2);
for (int k = 0; k <= 35; k++) {
t2[2] = word[k];
System.out.println(new String(t2));
}
});
thread2.start();
try {
thread2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
},"t"+i);
thread1.start();
thread1.join();
}
}
public static char[] copy(char[] a, char[] b){
for(int i = 0; i < a.length; i++){
b[i] = a[i];
}
return b;
}
}
写一个26字母和0-9数字不同长度组合的输出。需要用多线程
于 2022-07-15 16:41:13 首次发布