随笔分类 -  java线程

摘要:package com.testThread;/** * @author shkstart * @create 2021-08-06 10:07 */public class 实现线程安全的单例模式 { public static void main(String[] args) { Window4 阅读全文
posted @ 2021-08-06 10:17 林** 阅读(61) 评论(0) 推荐(0) 编辑
摘要://1000 表示延迟1秒执行, 5000表示每5秒执行一次public static void main(String[] args) throws InterruptedException { new Timer().schedule(new TimerTask() { @Override public void run()... 阅读全文
posted @ 2018-07-19 13:21 林** 阅读(108) 评论(0) 推荐(0) 编辑
摘要:1.newSingleThreadExecutor单任务线程池, 一次只执行一个任务 阅读全文
posted @ 2017-12-19 15:37 林** 阅读(800) 评论(0) 推荐(0) 编辑
摘要:1. newCachedThreadPool无上限线程池, 动态根据代码添加线程, 如果线程空闲60秒没有被使用,会自动关闭 阅读全文
posted @ 2017-12-19 15:33 林** 阅读(3151) 评论(0) 推荐(0) 编辑
摘要:1.newFixedThreadPool固定线程池, 使用完毕必须手动关闭线程池, 否则会一直在内存中存在, 阅读全文
posted @ 2017-12-19 15:27 林** 阅读(5758) 评论(0) 推荐(0) 编辑
摘要:1 package unit; 2 3 import java.util.concurrent.ArrayBlockingQueue; 4 import java.util.concurrent.ThreadPoolExecutor; 5 import java.util.concurrent.TimeUnit; 6 7 public class ThreadPoolExecu... 阅读全文
posted @ 2017-12-13 17:51 林** 阅读(342) 评论(0) 推荐(0) 编辑
摘要:1 package unit; 2 3 import java.util.concurrent.ArrayBlockingQueue; 4 5 /** 6 * 阻塞队列 7 * @author 54304 8 * 9 */ 10 public class BlockingQueue { 11 private int queueSize = 10; 12 ... 阅读全文
posted @ 2017-12-13 17:50 林** 阅读(205) 评论(0) 推荐(0) 编辑
摘要:1 package unit; 2 3 import java.util.PriorityQueue; 4 5 /** 6 * 非阻塞队列 7 * @author 54304 8 * 9 */ 10 public class BlockingQueue { 11 private int queueSize = 10; 12 private Prior... 阅读全文
posted @ 2017-12-13 17:48 林** 阅读(289) 评论(0) 推荐(0) 编辑
摘要:1 package unit; 2 3 import java.io.ByteArrayOutputStream; 4 import java.io.File; 5 import java.io.FileOutputStream; 6 import java.io.InputStream; 7 import java.math.BigDecimal; 8 imp... 阅读全文
posted @ 2017-12-13 17:05 林** 阅读(1522) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示