摘要:
package cn.ruhsang.state;//测试线程的优先级public class TestPriority { public static void main(String[] args) { //主线程的默认优先级 System.out.println(Thread.currentT 阅读全文
posted @ 2021-06-06 18:32
逆骨111
阅读(41)
评论(0)
推荐(0)
摘要:
package cn.ruhsang.state;//观察测试线程的状态public class TestState { public static void main(String[] args) throws InterruptedException { Thread thread = new 阅读全文
posted @ 2021-06-06 18:08
逆骨111
阅读(38)
评论(0)
推荐(0)
摘要:
package cn.ruhsang.state;//测试join方法 想象为插队public class TestJoin implements Runnable{ @Override public void run() { for (int i = 0; i < 100; i++) { Syst 阅读全文
posted @ 2021-06-06 17:36
逆骨111
阅读(57)
评论(0)
推荐(0)
摘要:
package cn.ruhsang.state;//测试礼让线程//礼让不一定成功看cpu心情public class TestYield { public static void main(String[] args) { MyYield myYield = new MyYield(); new 阅读全文
posted @ 2021-06-06 16:58
逆骨111
阅读(24)
评论(0)
推荐(0)
摘要:
package cn.ruhsang.state;import java.text.SimpleDateFormat;import java.util.Date;//模拟倒计时,获取当前系统时间public class TestSleep2 { public static void main(Str 阅读全文
posted @ 2021-06-06 16:40
逆骨111
阅读(32)
评论(0)
推荐(0)
摘要:
package cn.ruhsang.state;import cn.ruhsang.demo01.TestThread4;//模拟网络延时:放大问题的发生性.public class TestSleep implements Runnable{ //票数 private int ticketNum 阅读全文
posted @ 2021-06-06 16:18
逆骨111
阅读(107)
评论(0)
推荐(0)
摘要:
package cn.ruhsang.state;//测试停止线程//1.建议线程正常停止 >利用次数,不建议死循环//2.建议使用标志位 >设置一个标志位//3.不要使用stop或者destroy等过时或者JDK不建议使用的方法public class TestStop implements Ru 阅读全文
posted @ 2021-06-06 15:53
逆骨111
阅读(80)
评论(0)
推荐(0)
摘要:
package cn.rushangw;/*总结:lambda表达式只能有一行代码的情况下才能简化称为一行,如果有多行,那么就用代码块包裹//前提是接口维函数式接口(只有一个方法的接口就是函数式接口)多个参数也可以去掉参数类型,要去掉就都去掉,必须加上括号 */public class TestLa 阅读全文
posted @ 2021-06-06 14:59
逆骨111
阅读(54)
评论(0)
推荐(0)
浙公网安备 33010602011771号