惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Webroot Blog
Webroot Blog
AI
AI
P
Palo Alto Networks Blog
Attack and Defense Labs
Attack and Defense Labs
WordPress大学
WordPress大学
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
Spread Privacy
Spread Privacy
T
Tor Project blog
罗磊的独立博客
小众软件
小众软件
S
Security Affairs
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
NISL@THU
NISL@THU
博客园_首页
PCI Perspectives
PCI Perspectives
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Cloudflare Blog
A
About on SuperTechFans
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
宝玉的分享
宝玉的分享
G
GRAHAM CLULEY
雷峰网
雷峰网
F
Full Disclosure
I
Intezer
Cloudbric
Cloudbric
博客园 - 三生石上(FineUI控件)
U
Unit 42

Y先生的火箭屋

软件的七大设计原则 - Y先生的火箭屋 JavaSE使用socket与线程实现控制台版的聊天室功能 - Y先生的火箭屋 天天基金中持仓收益率和持有收益率的区别 - Y先生的火箭屋 在N个球中用天平称最少次数找出坏球 - Y先生的火箭屋 MySQL新增排名字段 - Y先生的火箭屋 Java中23种设计模式 - Y先生的火箭屋 金融上的做多做空和杠杆 - Y先生的火箭屋 JVM调优常用的调优参数 - Y先生的火箭屋 基于EasyExcel的配置型导入导出V1.0 - Y先生的火箭屋
Java常用代码工具类 - Y先生的火箭屋
Y先生 · 2023-05-17 · via Y先生的火箭屋

一、线程池

public class ThreadPool {

    /**
     * 核心线程
     */
    public static final int CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors() + 1;

    /**
     * 线程池最大线程数
     */
    public static final int MAX_POOL_SIZE = CORE_POOL_SIZE * 2;

    /**
     * 空闲线程回收时间
     */
    public static final int KEEP_ALIVE_TIME = 30;

    /**
     * 队列最大长度
     */
    public static final int QUEUE_CAPACITY = 128;

    private static final ExecutorService executorService =
            new ThreadPoolExecutor(CORE_POOL_SIZE,
                MAX_POOL_SIZE,
                KEEP_ALIVE_TIME,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(QUEUE_CAPACITY),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.CallerRunsPolicy());

    private ThreadPool() {

    }

    public static void execute(Runnable task) {
        executorService.execute(task);
    }

    public static void shutdown() {
        if(!executorService.isShutdown()){
            executorService.shutdown();
        }
    }

    public static Future submit(Runnable task){
        return executorService.submit(task);
    }

    public static boolean cancel(Future future){
        if(future != null && !future.isCancelled()){
            return future.cancel(true);
        }
        return false;
    }
}

二、EasyExcel一列单元格导出多张图片

/**
     *
     * @param context
     * @param imageDataList 图片列表
     * @param imgColIndex 图片列
     */
    private void setImage(CellWriteHandlerContext context, List<ImageData> imageDataList, int imgColIndex) {
        Sheet sheet = context.getWriteSheetHolder().getSheet();
        Cell cell = context.getCell();
        // 图片数量
        int maxSize = imageDataList.size() > 1 ? imageDataList.size() : 1;
        // 根据图片数量设置图片列的宽度
        sheet.setColumnWidth(imgColIndex, (int)(18 * maxSize + 0.72) * 256);
        // 图片宽度,单位px,自己设置咯
        int picWidth = Units.pixelToEMU(125);
        Drawing drawing = sheet.getDrawingPatriarch();
        if (drawing == null) {
            drawing = sheet.createDrawingPatriarch();
        }
        for (int i = 0; i < imageDataList.size(); i++) {
            int index = sheet.getWorkbook().addPicture(imageDataList.get(i).getImage(), XSSFWorkbook.PICTURE_TYPE_PNG);
            // 设置图片坐标和位置 dx1, dy1, dx2, dy2, col1, row1, col2, row2
            // (dx1, dy1)是起始单元格图片左上角的坐标
            // (dx2, dy2)是结束单元格图片右下角的坐标
            // (col1, row1)是起始单元格位置
            // (col2, row2)是结束单元格位置
            ClientAnchor anchor = drawing.createAnchor(picWidth, 0, picWidth + picWidth * i,
                0,cell.getColumnIndex(), cell.getRowIndex(), cell.getColumnIndex(), cell.getRowIndex() + 1);
            // 设置图片可以随着单元格移动
            anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
            drawing.createPicture(anchor, index);
        }
    }

|´・ω・)ノ

ヾ(≧∇≦*)ゝ

(☆ω☆)

(╯‵□′)╯︵┴─┴

 ̄﹃ ̄

(/ω\)

∠( ᐛ 」∠)_

(๑•̀ㅁ•́ฅ)

→_→

୧(๑•̀⌄•́๑)૭

٩(ˊᗜˋ*)و

(ノ°ο°)ノ

(´இ皿இ`)

⌇●﹏●⌇

(ฅ´ω`ฅ)

(╯°A°)╯︵○○○

φ( ̄∇ ̄o)

ヾ(´・ ・`。)ノ"

( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃

(ó﹏ò。)

Σ(っ °Д °;)っ

( ,,´・ω・)ノ"(´っω・`。)

╮(╯▽╰)╭

o(*////▽////*)q

>﹏<

( ๑´•ω•) "(ㆆᴗㆆ)

😂

😀

😅

😊

🙂

🙃

😌

😍

😘

😜

😝

😏

😒

🙄

😳

😡

😔

😫

😱

😭

💩

👻

🙌

🖕

👍

👫

👬

👭

🌚

🌝

🙈

💊

😶

🙏

🍦

🍉

😣

Source: github.com/k4yt3x/flowerhd