Ai
1 Star 0 Fork 59

Yangjianwei/java-performance

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ThreadTest1.java 775 Bytes
一键复制 编辑 原始数据 按行查看 历史
闲.大赋(李家智) 提交于 2019-10-26 17:23 +08:00 . refine doc
package com.ibeetl.code.ch03;
import java.util.HashMap;
import java.util.Map;
/**
* jstack 观察线程栈
*/
public class ThreadTest1 {
static int max = 10;
public static void main(String[] args){
Thread thread = new Thread("calc-thread"){
public void run(){
while(true){
Map map = readData();
//模拟手误,应该是!map.isEmpty()
if(map.isEmpty()){
break;
}
}
}
};
thread.start();
}
public static Map readData(){
Map map = new HashMap();
for(int i=0;i<1000;i++){
map.put(i," value-"+i);
}
// sleep(100);
return map;
}
public static void sleep(int time){
try {
Thread.sleep(time);
}catch(Exception ex){
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/higher/java-performance.git
git@gitee.com:higher/java-performance.git
higher
java-performance
java-performance
master

搜索帮助