0
点赞
收藏
分享

微信扫一扫

Java并发编程核心_使用Jconsole观察线程

package com.neu.day01;

public class Thread01 {
public static void main(String[] args) {
//jdk 1.8之前匿名类部类
new Thread("new01"){
@Override
public void run() {
browseNews();
}
}.start();
//jdk 1.8 Lambda编码方式
Thread thread = new Thread(() -> {
browseNews();
});
thread.setName("news2");
thread.start();

Thread thread1 = new Thread(Thread01::enjoyMusic);
thread1.setName("music");
thread1.start();
}

private static void browseNews(){
while (true){
System.out.println("The good news");
try{
Thread.sleep(1000);
}catch (Exception e){
e.printStackTrace();
}
}
}
private static void enjoyMusic(){
while (true){
System.out.println("The good music");
try{
Thread.sleep(1000);
}catch (Exception e){
e.printStackTrace();
}
}
}
}

终端操作

Java并发编程核心_使用Jconsole观察线程_ide

jconsole观察线程

Java并发编程核心_使用Jconsole观察线程_数据库_02
Java并发编程核心_使用Jconsole观察线程_数据库_03


举报

相关推荐

0 条评论