摘要:
线程状态 thread.getState() Thread.State.TERMINATED public class TestThreadState{ public static void main(String[] args) { Thread thread = new Thread(()->{ 阅读全文
posted @ 2021-03-07 21:40
要给小八赚罐头钱
阅读(187)
评论(0)
推荐(0)
摘要:
线程强制执行 join public class TestJoin implements Runnable{ @Override public void run() { for (int i = 0; i < 100; i++) { System.out.println("靠边!俺来了!"+i); 阅读全文
posted @ 2021-03-07 16:53
要给小八赚罐头钱
阅读(14)
评论(0)
推荐(0)
摘要:
线程礼让yield 礼让不一定成功哦~ public class TestYield { public static void main(String[] args) { Yield yield = new Yield(); new Thread(yield,"A").start(); new T 阅读全文
posted @ 2021-03-07 16:31
要给小八赚罐头钱
阅读(31)
评论(0)
推荐(0)
摘要:
模拟打印当前时间 import java.text.SimpleDateFormat;import java.util.Date;public class TestThreadSleep implements Runnable{ private boolean flag=true; @Overri 阅读全文
posted @ 2021-03-07 16:19
要给小八赚罐头钱
阅读(69)
评论(0)
推荐(0)
摘要:
线程停止 不要用自带的stop方法,设置flag标志位停止线程。 public class TestThreadStop implements Runnable{ private boolean flag=true; @Override public void run() { int i=0; wh 阅读全文
posted @ 2021-03-07 15:34
要给小八赚罐头钱
阅读(39)
评论(0)
推荐(0)
浙公网安备 33010602011771号