Loading

摘要: pom.xml 配置<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties> 阅读全文
posted @ 2020-03-15 00:37 Rzk 阅读(268) 评论(0) 推荐(0)
摘要: 🔒Lock是显式锁(手动开启和关闭锁,别忘记关闭锁)synchronized是隐式锁,处理作用域自动释放 🔒Lock只有代码块锁,synchronized有代码块锁和方法锁 🔒使用Lock锁,JVM将花费较少的时间来调度线程,性能更好。并且具有更好的扩展性(提供更多的子类) 🔒优先使用顺序: 阅读全文
posted @ 2020-03-13 19:27 Rzk 阅读(118) 评论(0) 推荐(0)
摘要: //測試lock鎖 public class TestLock { public static void main(String[] args) { TestLock2 testLock2 = new TestLock2(); new Thread(testLock2).start(); new T 阅读全文
posted @ 2020-03-13 19:21 Rzk 阅读(122) 评论(0) 推荐(0)
摘要: //死锁:多个线程相互抱着对方需要的资源,然后形成僵局 public class DeadLock { public static void main(String[] args) { Makeup makeup1 = new Makeup(0,"小老虎"); Makeup makeup2 = ne 阅读全文
posted @ 2020-03-13 18:23 Rzk 阅读(163) 评论(0) 推荐(0)
摘要: 1.下面这一例子会造成线程不安全 会取出负数,会同时一起抢 要是剩最后一张票的时候 会同时取出一,这样就造成线程不安全 //不安全买票 public class UnsafeBuyTicket { public static void main(String[] args) { BuyTicket 阅读全文
posted @ 2020-03-13 16:43 Rzk 阅读(158) 评论(0) 推荐(0)
摘要: public class UnsafeBuyTicket { public static void main(String[] args) { BuyTicket station = new BuyTicket(); new Thread(station,"苦逼的我").start(); new T 阅读全文
posted @ 2020-03-13 16:39 Rzk 阅读(147) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/xiaomu_347/article/details/80627647?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-t 阅读全文
posted @ 2020-03-13 14:58 Rzk 阅读(180) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/wonad12/article/details/80499761 阅读全文
posted @ 2020-03-13 14:56 Rzk 阅读(101) 评论(0) 推荐(0)
摘要: public static void main(String[] args) throws InterruptedException { //sleep打印系统时间 while(true){ //打印当前时间 Date date = new Date(System.currentTimeMillis 阅读全文
posted @ 2020-03-13 10:49 Rzk 阅读(218) 评论(0) 推荐(0)
摘要: 解决办法: 1.在Tomcat目录下的lib文件夹中加入jstl 2. 在maven项目中加入jstl包: 阅读全文
posted @ 2020-03-13 01:29 Rzk 阅读(730) 评论(0) 推荐(0)