-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleThread.java
More file actions
50 lines (37 loc) · 1.04 KB
/
SimpleThread.java
File metadata and controls
50 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class SimpleThread {
native static void check(Thread thr, ClassLoader cl);
static MyThread t;
public static void main(String args[]) throws Throwable{
// System.loadLibrary("a");
t = new MyThread();
System.out.println("Creating and running 5 threads...");
for(int i = 0; i < 5; i++) {
Thread thr = new Thread(t,"MyThread"+i);
thr.start();
// check(thr, thr.getContextClassLoader());
try {
thr.join();
} catch (Throwable t) {
}
}
}
}
class MyThread implements Runnable {
Thread t;
public MyThread() {
}
public void run() {
/* NO-OP */
try {
"a".getBytes("ASCII");
excep();
Thread.sleep(1000);
} catch (java.lang.InterruptedException e){
e.printStackTrace();
} catch (Throwable t) {
}
}
public void excep() throws Throwable{
throw new Exception("Thread Exception from MyThread");
}
}