随笔分类 - java线程
摘要:package com.testThread;/** * @author shkstart * @create 2021-08-06 10:07 */public class 实现线程安全的单例模式 { public static void main(String[] args) { Window4
阅读全文
摘要://1000 表示延迟1秒执行, 5000表示每5秒执行一次public static void main(String[] args) throws InterruptedException { new Timer().schedule(new TimerTask() { @Override public void run()...
阅读全文
摘要:1.newSingleThreadExecutor单任务线程池, 一次只执行一个任务
阅读全文
摘要:1. newCachedThreadPool无上限线程池, 动态根据代码添加线程, 如果线程空闲60秒没有被使用,会自动关闭
阅读全文
摘要:1.newFixedThreadPool固定线程池, 使用完毕必须手动关闭线程池, 否则会一直在内存中存在,
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文