-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAboutThreadLocal.java
More file actions
executable file
·40 lines (38 loc) · 1.21 KB
/
AboutThreadLocal.java
File metadata and controls
executable file
·40 lines (38 loc) · 1.21 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
/* */ package multithreads;
/* */
/* */ import java.util.concurrent.TimeUnit;
/* */
/* */ public class AboutThreadLocal {
/* 6 */ static ThreadLocal<Person> tl = new ThreadLocal<>();
/* */
/* */ public static void main(String[] args) {
/* 9 */ (new Thread(() -> {
/* */
/* */ try {
/* */ TimeUnit.SECONDS.sleep(2L);
/* 13 */ } catch (InterruptedException e) {
/* */ e.printStackTrace();
/* */ }
/* */ System.out.println(tl.get());
/* 17 */ })).start();
/* */
/* 19 */ (new Thread(() -> {
/* */
/* */ try {
/* */ TimeUnit.SECONDS.sleep(1L);
/* 23 */ } catch (InterruptedException e) {
/* */ e.printStackTrace();
/* */ }
/* */ tl.set(new Person());
/* 27 */ })).start();
/* */ }
/* */
/* */ static class Person
/* */ {
/* 32 */ String name = "zhangsan";
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/multithreads/AboutThreadLocal.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/