62,623
社区成员
发帖
与我相关
我的任务
分享
public class Test {
public static void main(String[] args) {
try {
Thread[] thread = new Thread[10];
for (int i=0; i<thread.length; i++) {
thread[i] = new Thread() {
public void run() {
try {
Runtime.getRuntime().exec("cmd /C notepad");
} catch (Throwable e) { //上面的代码这里的前面漏了个}
e.printStackTrace();
}
}
};
thread[i].start();
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
public class Test {
public static void main(String[] args) {
try {
Thread[] thread = new Thread[10];
for (int i=0; i<thread.length; i++) {
thread[i] = new Thread() {
public void run() {
try {
Runtime.getRuntime().exec("cmd /C notepad");
catch (Throwable e) {
e.printStackTrace();
}
}
};
thread[i].start(); //上面遗漏了
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
public class Test {
public static void main(String[] args) {
try {
Thread[] thread = new Thread[10];
for (int i=0; i<thread.length; i++) {
thread[i] = new Thread() {
public void run() {
try {
Runtime.getRuntime().exec("cmd /C notepad");
catch (Throwable e) {
e.printStackTrace();
}
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}