2023年6月20日

摘要: 首先需要有两个或两个以上的服务器 我们这里模拟一下 开两个端口运行项目 我这里用cmd窗口模拟 java -jar jar包名 java -jar jar包名 --server.port=8089 启动后配置Nginx配置文件 进入nginx目录找到配置文件 编辑 在http下配置负载均衡 (这里a 阅读全文
posted @ 2023-06-20 15:49 搁浅fff 阅读(11) 评论(0) 推荐(0) 编辑

2023年3月22日

摘要: package com.Java;import java.util.concurrent.*;public class TestPool { public static void main(String[] args) { //创建服务 创建线程池 ExecutorService service = 阅读全文
posted @ 2023-03-22 19:59 搁浅fff 阅读(17) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;public class Testflag { public static void main(String[] args) { TV tv = new TV(); new Player(tv).start(); new Watcher(tv).start(); } 阅读全文
posted @ 2023-03-22 19:20 搁浅fff 阅读(11) 评论(0) 推荐(0) 编辑

2023年3月7日

摘要: package com.Java;import java.util.concurrent.locks.ReentrantLock;//可重入锁public class TestLock { public static void main(String[] args) { TestLock2 test 阅读全文
posted @ 2023-03-07 19:26 搁浅fff 阅读(67) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//死锁案例 互相持有对方的锁 并且想要拿到对方的资源public class DeadLock { public static void main(String[] args) { Makeup makeup = new Makeup(0, "灰姑凉"); Mak 阅读全文
posted @ 2023-03-07 19:05 搁浅fff 阅读(10) 评论(0) 推荐(0) 编辑

2023年3月6日

摘要: package com.Java;//银行不安全案例 两个人同时取钱//使用 synchronized和synchronized块 可以锁住对象 保证线程的安全性public class TestBank { public static void main(String[] args) { Acco 阅读全文
posted @ 2023-03-06 20:01 搁浅fff 阅读(14) 评论(0) 推荐(0) 编辑

2023年3月4日

摘要: package com.Java;//守护线程//虚拟机不需要等待守护线程执行完//虚拟机必须等待用户线程执行完public class TestDaemon { public static void main(String[] args) { God god = new God(); Yous y 阅读全文
posted @ 2023-03-04 17:09 搁浅fff 阅读(12) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//线程优先级调度// 注意:不是调整了优先级就一定会被cpu先执行 只是提高了执行概率 一切还是要看cpu调度public class TestPriority { public static void main(String[] args) { System.o 阅读全文
posted @ 2023-03-04 16:39 搁浅fff 阅读(31) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//观测线程状态public class TestState { public static void main(String[] args) throws InterruptedException { Thread thread = new Thread(() - 阅读全文
posted @ 2023-03-04 16:15 搁浅fff 阅读(15) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//Join 线程插队 必须执行完再执行其他线程public class TestJoin implements Runnable { @Override public void run() { for (int i = 0; i < 500; i++) { Sys 阅读全文
posted @ 2023-03-04 14:27 搁浅fff 阅读(10) 评论(0) 推荐(0) 编辑