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 ...
随机推荐
- JuJu团队11月30号工作汇报
JuJu团队11月30号工作汇报 JuJu Scrum 团队成员 今日工作 剩余任务 困难 于达 提供类似generator的数据产生接口 改进代码 对julia不够熟悉 婷婷 和队友一起 ...
- 使用Python绘制漫步图
代码如下: import matplotlib.pyplot as plt from random import choice class RandomWalk(): def __init__(sel ...
- RadioGroup的使用
前言: 使用RadioGroup就可以在选择情况多的时候,简化代码 RadioGroup 使用互斥选择时,会使用RadioGroup标签下面RadioButton,如下面的代码:(这样写下来,男和女的 ...
- C++编程学习(八)new&delete动态内存分配
前段时间楼主忙着期末大作业,停更了一段,今天刚好在做机器人课程的大作业时,和同组的小伙伴利用python做了工业机器人的在线编程,突然想起来很久没有阅读大型工程了,马上补上- 接下来的几篇博客主要是博 ...
- 二十九、SAP中输出漂亮的表格
一.代码如下 二.输出效果如下 *&---------------------------------------------------------------------* *& ...
- msf中arp_sweep使用报错:usbmon1:ERROR while getting interface flags:no such device
在许多的工具使用中,会出现很多的错误,要养成先思考再去寻找帮助的习惯 在用use命令使用arp_sweep模块的时候爆出错误:usbmon1:ERROR while getting interface ...
- Python 异常处理(Try...Except)
版权所有,未经许可,禁止转载 章节 Python 介绍 Python 开发环境搭建 Python 语法 Python 变量 Python 数值类型 Python 类型转换 Python 字符串(Str ...
- kafka源码系列之mysql数据增量同步到kafka
一,架构介绍 生产中由于历史原因web后端,mysql集群,kafka集群(或者其它消息队列)会存在一下三种结构. 1,数据先入mysql集群,再入kafka 数据入mysql集群是不可更改的,如何再 ...
- idea自定义快捷鍵
一 生成方法注释 1. File -> Settings... 2. Editor -> Live Templates,点击最右边的+ 3. 依自己情况选择,我这里选择的 Live Te ...
- windows2000 堆溢出 利用原理
源于0day安全一书 1.堆的分配原理 申请堆空间 HANDLE address = HeapCreate(0,0x1000,0x10000) address就是堆的地址 在address+0x ...