package org.example;
import org.junit.Test;
import java.io.IOException;
public class TestThread {
@Test
public void test1() throws IOException {
for (int i = 0; i < 100; i++) {
f(i);
}
System.out.println("xxxxxxxxxx");
System.in.read();
}
public void f(int subType) {
String t = String.valueOf(subType);
new Thread() {
@Override
public void run() {
System.out.println(subType + " " + t);
}
}.start();
}
}
/*
xxxxxxxxxx
81 81
57 57
96 96
34 34
86 86
87 87
88 88
50 50
89 89
90 90
91 91
92 92
93 93
49 49
94 94
95 95
56 56
43 43
37 37
8 8
51 51
31 31
97 97
55 55
1 1
33 33
36 36
4 4
99 99
6 6
52 52
40 40
35 35
53 53
46 46
3 3
77 77
30 30
47 47
59 59
54 54
7 7
78 78
27 27
98 98
83 83
85 85
48 48
25 25
5 5
29 29
26 26
75 75
38 38
80 80
79 79
58 58
84 84
0 0
82 82
28 28
39 39
62 62
23 23
63 63
22 22
44 44
21 21
24 24
20 20
65 65
60 60
64 64
67 67
61 61
19 19
42 42
66 66
17 17
68 68
16 16
18 18
70 70
69 69
15 15
71 71
14 14
72 72
13 13
41 41
74 74
12 12
73 73
32 32
10 10
2 2
76 76
11 11
9 9
45 45
*/
java函数的参数传递到callback时,不会顺序错乱(和js不同)
最新推荐文章于 2024-08-15 14:47:41 发布