摘要: 线程池:重点 三大方法 七大参数 四种拒绝策略 使用池化技术的理由: 我们的程序伴随着创建销毁线程十分浪费资源, 所以使用线程池,先创建线程,随用随取,用完归还 简单来说就是节约了资源。 使用线程池的好处:节省资源(最大并发线程数可控);提高了响应速度;方便管理三大方法: 1.newFixedThr 阅读全文
posted @ 2020-10-25 17:23 ITYW 阅读(265) 评论(0) 推荐(0) 编辑
摘要: * 读写锁: * 读读可以共存 * 读写不能共存 * 写写不能共存 * * 独占锁(写锁) * 共享锁(读锁) */public class ReadWriteLockTest { public static void main(String[] args) { MyCache myCache = 阅读全文
posted @ 2020-11-18 00:18 ITYW 阅读(122) 评论(0) 推荐(0) 编辑
摘要: /** * 线程通信 * * @Author: ITYW * @Create 2020 - 07 - 29 - 9:43 */public class Thread_wait_notify_notifyAll { public static void main(String[] args) { Nu 阅读全文
posted @ 2020-10-26 19:54 ITYW 阅读(96) 评论(0) 推荐(0) 编辑
摘要: /** * 线程安全 Lock方式 * * @Author: ITYW * @Create 2020 - 10 - 26 - 19:16 */public class RunnableSecurity_Lock { public static void main(String[] args) { R 阅读全文
posted @ 2020-10-26 19:48 ITYW 阅读(167) 评论(0) 推荐(0) 编辑
摘要: /** * Runnable方式线程安全 同步方法 * * @Author: ITYW * @Create 2020 - 10 - 26 - 18:59 */public class RunnableSecurity02 { public static void main(String[] args 阅读全文
posted @ 2020-10-26 19:42 ITYW 阅读(117) 评论(0) 推荐(0) 编辑
摘要: /** * Runnable方式线程安全 同步代码块 * * @Author: ITYW * @Create 2020 - 10 - 26 - 18:47 */public class RunnableSecurity { public static void main(String[] args) 阅读全文
posted @ 2020-10-26 19:41 ITYW 阅读(73) 评论(0) 推荐(0) 编辑
摘要: /** * 基于Thread类的线程安全问题1 同步代码块方式 * * @Author: ITYW * @Create 2020 - 10 - 26 - 18:35 */public class ThreadSecurity02 { public static void main(String[] 阅读全文
posted @ 2020-10-26 19:38 ITYW 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 1.继承Thread类的方式 同步方法(以卖票为例) /** * 基于Thread类的线程安全问题1 同步方法 * * @Author: ITYW * @Create 2020 - 10 - 26 - 18:16 */public class ThreadSecurity { public stat 阅读全文
posted @ 2020-10-26 19:36 ITYW 阅读(135) 评论(0) 推荐(0) 编辑
摘要: /** * 线程中常用的方法 * 1.start():启动线程,运行run()方法 * 2.run():是Thread类重写的方法,将线程需要执行的操作写在此方法中、 * 3.currentThread():返回当前线程 * 4.setName():设置线程名 * 5.getName():获取线程名 阅读全文
posted @ 2020-10-25 23:19 ITYW 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 继承Thread类1.新建一个线程类继承Thread类2.重写run()3.在main方法中实例化线程对象4.调用start()public class Thread01{ public static void main(String []args){ MyThread t = new MyThre 阅读全文
posted @ 2020-10-25 17:21 ITYW 阅读(58) 评论(0) 推荐(0) 编辑