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 相同的更多相关文章

  1. Thread.sleep 与Thread.currentThread.sleep

    参考博客: https://blog.csdn.net/guangyinglanshan/article/details/51645053 公司项目近段时间要使用thread, 个人想去了解Threa ...

  2. 源码查看Thread.interrupted()和Thread.currentThread().isInterrupted()区别

    JAVA线程状态.线程START方法源码.多线程.JAVA线程池.如何停止一个线程等多线程问题 这两个方法有点容易记混,这里就记录一下源码. Thread.interrupted()和Thread.c ...

  3. Thread.sleep()和Thread.currentThread().sleep()区别

    先看一下代码 public class Thread1 extends Thread{ @Override public void run() { try { System.out.println(& ...

  4. Thread thread2 = new Thread()

    Thread thread2 = new Thread() { @Override public void run() { test.function(); } }; thread1.start(); ...

  5. 1,Thread 概念以及Thread 的6个状态

    Thread 有6个状态 , NEW, RUNNABLE , BLOCKED, WATTING, TIMED WAITING, TERMINATED 1.NEW至今尚未启动的线程的状态.2.RUNNA ...

  6. Thread之三:Thread Join()的用法

    一.join用法 join()和wait()不会释放锁,join()是Thread的方法,wait()是Object的方法 1.join方法定义在Thread类中,则调用者必须是一个线程 例如: Th ...

  7. Thread系列之Thread.Sleep(0)

    线程这一概念,可以理解成进程中的一个小单元.这个单元是一个独立的执行单元,但是与进程中的其他线程共享进程中的内存单元. 由于Cpu资源是有限的,所以进程中的多个线程要抢占Cpu,这也导致进程中的多个线 ...

  8. PHP版本VC6和VC9、Non Thread Safe和Thread Safe的区别

    链接:http://www.cnblogs.com/neve/articles/1863853.html 想更新个PHP的版本,PHP的windows版本已经分离出来了,见http://windows ...

  9. 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 ...

随机推荐

  1. 关于 CDN 负载均衡 网页请求过程等

    链接 1 [转]浅谈一个网页打开的全过程(涉及DNS.CDN.Nginx负载均衡等)  https://www.cnblogs.com/xuan52rock/p/6845637.html 2 闲话 C ...

  2. Robot set variable if

    ${strid} Set Variable If '${row}' =='2' LFFD_TANK_RAMP ... '${row}' =='3' LFFD_TANK_LANDING

  3. P 1007 素数对猜想

    转跳点:

  4. spring boot 使用swagger

    在pom.xml中添加maven依赖 <dependency> <groupId>io.springfox</groupId> <artifactId> ...

  5. 微信小程序调用用百度地图天气功能

    #小程序之调用百度地图天气功能 本篇博客主要介绍小程序在百度地图中获取天气信息,如有不全请指出.下面先上效果图 主要内容 百度地图API的个人密钥,也就是AK 请求百度地图API接口数据 获取到的信息 ...

  6. 公司网络能ping通ip,不能ping域名

    第一天去公司,就因为网络问题弄了大半天.只能ping通ip,不能ping域名.网上查了各种方式都不行,刷新dns缓存.说是什么域名解析问题.dns的问题.公司里好几个人都看了看不能解决.领导让重装系统 ...

  7. (转)zookeeper理解

    分布式服务框架 Zookeeper -- 管理分布式环境中的数据 Zookeeper 分布式服务框架是 Apache Hadoop 的一个子项目,它主要是用来解决分布式应用中经常遇到的一些数据管理问题 ...

  8. Solve Error: Could not find the certificate xxxx.com. at ServerlessCustomDomain.<anonymous>

    When runs "serverless create_domain", we may get the following error: Could not find the c ...

  9. JavaWeb高级编程(下篇)

    Java标准标签库 JSP标签语法中包含一些简写可以帮助轻松编写JSP.这些简写中第一个就是taglib指令. <%@ taglib prefix="c" uri=" ...

  10. Codeforces Round #616 (Div. 2) 题解

    A. Even But Not Even 题意: 定义一个数所有位置的和为偶数它本身不为偶数的数为ebne,现在给你一个数字字符串,你可以删除任意位置上的数字使其变为ebne输出任意改变后的结果,如果 ...