Skip to content

Commit d2e4136

Browse files
committed
add this escape
1 parent 09304e0 commit d2e4136

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.yiyun;
2+
3+
public class ThreadThisEscape {
4+
private int weight=0;
5+
public ThreadThisEscape(){
6+
new Thread(new EscapeRunnable()).start();
7+
weight=1;
8+
// 模拟构造函数耗时
9+
for (int i = 0; i < 1000000; i++)
10+
{
11+
12+
}
13+
14+
}
15+
private class EscapeRunnable implements Runnable
16+
{
17+
@Override
18+
public void run()
19+
{
20+
System.out.println(ThreadThisEscape.this.weight);
21+
}
22+
}
23+
24+
public static void main(String[] args) {
25+
new ThreadThisEscape();
26+
}
27+
28+
}

0 commit comments

Comments
 (0)