Thread.sleep 与Thread.currentThread.sleep 相同
package com.citi.tm.api.trade.mongo;
public class ThreadTest {
public static void main(String[] args) {
Runnable r =
() -> {
try {
//Thread.currentThread().sleep(15000);//a, b, sleep
Thread.sleep(15000);//a, b, sleep
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(
"Thread id:"
+ Thread.currentThread().getId()
+ ", Thread name:"
+ Thread.currentThread().getName());
};
Thread a = new Thread(r, "a");
Thread b = new Thread(r, "b");
System.out.println("start");
a.start();
b.start();
System.out.println("end");
}
}
Thread.sleep 与Thread.currentThread.sleep 相同的更多相关文章
- Thread.sleep 与Thread.currentThread.sleep
参考博客: https://blog.csdn.net/guangyinglanshan/article/details/51645053 公司项目近段时间要使用thread, 个人想去了解Threa ...
- 源码查看Thread.interrupted()和Thread.currentThread().isInterrupted()区别
JAVA线程状态.线程START方法源码.多线程.JAVA线程池.如何停止一个线程等多线程问题 这两个方法有点容易记混,这里就记录一下源码. Thread.interrupted()和Thread.c ...
- Thread.sleep()和Thread.currentThread().sleep()区别
先看一下代码 public class Thread1 extends Thread{ @Override public void run() { try { System.out.println(& ...
- Thread thread2 = new Thread()
Thread thread2 = new Thread() { @Override public void run() { test.function(); } }; thread1.start(); ...
- 1,Thread 概念以及Thread 的6个状态
Thread 有6个状态 , NEW, RUNNABLE , BLOCKED, WATTING, TIMED WAITING, TERMINATED 1.NEW至今尚未启动的线程的状态.2.RUNNA ...
- Thread之三:Thread Join()的用法
一.join用法 join()和wait()不会释放锁,join()是Thread的方法,wait()是Object的方法 1.join方法定义在Thread类中,则调用者必须是一个线程 例如: Th ...
- Thread系列之Thread.Sleep(0)
线程这一概念,可以理解成进程中的一个小单元.这个单元是一个独立的执行单元,但是与进程中的其他线程共享进程中的内存单元. 由于Cpu资源是有限的,所以进程中的多个线程要抢占Cpu,这也导致进程中的多个线 ...
- PHP版本VC6和VC9、Non Thread Safe和Thread Safe的区别
链接:http://www.cnblogs.com/neve/articles/1863853.html 想更新个PHP的版本,PHP的windows版本已经分离出来了,见http://windows ...
- Part 92 Significance of Thread Join and Thread IsAlive functions
Thread.Join & Thread.IsAlive functions Join blocks the current thread and makes it wait until th ...
随机推荐
- json字符串转java对象,json中字段名称与对象属性名称不一致
json字符串转java对象,json字段名称与对象属性名称不一致可以在对象属性上添加注解@SerializedName解决
- Spring加载Properties配置文件的三种方式
一.通过 context:property-placeholder 标签实现配置文件加载 1) 用法: 1.在spring.xml配置文件中添加标签 <context:property-plac ...
- OpenCV HOGDescriptor 参数图解
防止以后再次掉入坑中,决定还是在写写吧 OpenCV中的HOG特征提取功能使用了HOGDescriptor这个类来进行封装,其中也有现成的行人检测的接口.然而,无论是OpenCV官方说明文档还是各个中 ...
- LeetCode题解汇总(包括剑指Offer和程序员面试金典,持续更新)
LeetCode题解汇总(持续更新,并将逐步迁移到本博客列表中) LeetCode题解分类汇总(包括剑指Offer和程序员面试金典) 剑指Offer 序号 题目 难度 03 数组中重复的数字 简单 0 ...
- tomcat启动报错The JRE could not be found.Edit the server and change the JRE location
解决: 在Windows->Preferences->Server->Runtime Environments 选择Tomcat->Edit,在jre中选择相应的jdk版本,完 ...
- 地图js及json包
echarts github上的地图js及json包:https://github.com/apache/incubator-echarts/tree/master/map 上面链接没有县及的地图js ...
- 关于TCP连接的3次握手和4次挥手
3次握手: 关键在于双方都需要确认自己的发信和收信功能正常,收信功能通过接收对方信息得到确认,发信功能需要发出信息—>对方回复信息得到确认. 举个日常例子,打电话时我们对话如下: 如上,需要第三 ...
- Web.config中executionTimeout的单位
executionTimeout:表示允许执行请求的最大时间限制,单位为秒
- 【转】美团 MySQL 数据实时同步到 Hive 的架构与实践
文章转载自公众号 美团技术团队 , 作者 萌萌 背景 在数据仓库建模中,未经任何加工处理的原始业务层数据,我们称之为ODS(Operational Data Store)数据.在互联网企业中,常见的 ...
- JNI操作二维数组
之前的文章讲解了有关JNI使用方法,这篇文章进阶一点,介绍下JNI操作二维数组的方法.有了之前文章的操作JNI的方法,这里直接上代码了. Java代码部分 package com.testjni; p ...