-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadtest.java
More file actions
33 lines (28 loc) · 797 Bytes
/
Copy paththreadtest.java
File metadata and controls
33 lines (28 loc) · 797 Bytes
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
package factory;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @program: Java-learn
* @description: 多线程下 运行map
* @author: anthony1314
* @create: 2020-04-19 00:45
**/
public class threadtest extends Thread{
private String name;
private static Map<String, String> mp = new ConcurrentHashMap<>();
public threadtest(String ss){
name = ss;
}
public static void main(String[] args) {
threadtest t1 = new threadtest("aaa");
threadtest t2 = new threadtest("bbb");
threadtest t3 = new threadtest("ccc");
t1.start();
t2.start();
t3.start();
}
public void run(){
mp.put(name, "qqq");
System.out.println(mp.size()+ "thread" + name + "运行完成");
}
}