
线程池
文章平均质量分 73
自驱
ALOHA HEJA HE
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【golang】WorkerPool 三种实现方式
WorkerPool 的多种实现方式use golang原创 2022-09-25 23:36:34 · 841 阅读 · 0 评论 -
【golang】认识 Go 并发+
总之,Go 使用的是 Goroutines 和 Threads,它们在并发执行函数的组合中都是必不可少的。相比之下,线程开始于一个更大的空间,以及一个称为保护页的内存区域,该区域充当一个线程的内存。它们非常轻量级,不像操作系统线程,而是数百个 Goroutines 可以被多路复用到一个操作系统线程上(Go 有它的运行时调度器) ,只需要最小的上下文切换开销!Scheduler 的工作是将可运行的 goroutine (G)分布在运行在一个或多个处理器(P)上的多个工作 OS 线程(M)上。原创 2022-09-03 21:06:21 · 449 阅读 · 0 评论 -
【IO】Java异步非阻塞编程的几种方式
1 服务端执行,最简单的同步调用方式:缺陷: 服务端响应之前,IO会阻塞在: java.net.SocketInputStream#socketRead0 的native方法上:2 JDK NIO & Future java 1.5之后优点:主线程可以不用等待IO响应,可以去做点其他的,比如说再发送一个IO请求,可以等到一起返回; 缺点: 主线程在等待结果返回过程中依然需要等待,没有根本解决此问题;3 使用Callback回调方式优点:主线程完成发送请求后,再也不用关心这.原创 2021-02-25 20:12:33 · 419 阅读 · 0 评论 -
【线程池】java 1.8 ThreadPoolExecutor 类源码解读
1 线程池:why?主要解决1 异步任务 2 生产者消费者场景2 参数详解2.1 核心线程数// 小于核心线程数:任务提交时创建新的线程,即使其他线程空闲;When a new task is submitted in method {@link #execute(Runnable)}, and fewer than corePoolSize threads are running, a new thread is created to handle the request, eve..原创 2021-01-30 16:52:59 · 338 阅读 · 2 评论 -
【Daemon】守护和非守护线程鲜为人知的事实
1 总结(英文+翻译)如下:Non-daemon threads are also known as ‘user’ threads // 非守护程序线程也称为“用户”线程。JVM will not exit even if only 1 non-daemon (i.e. user) thread is alive. On the other hand, JVM will exit even if multiple daemon threads are alive. // 即使只有1个非守护程序(即用户原创 2020-12-11 10:01:50 · 408 阅读 · 1 评论 -
【面试】--三个线程轮流打印ABC
1 lock实现public class ABCLock { private static Lock lock = new ReentrantLock(); private static Condition conditionA = lock.newCondition(); private static Condition conditionB = lock.ne原创 2020-08-16 15:13:53 · 376 阅读 · 0 评论 -
【线程池】线程池的线程遇到异常后去哪里?怎么处理?
1 四种解决任务代码抛异常的方案:在我们提供的Runnable的run方法中捕获任务代码可能抛出的所有异常,包括未检测异常 使用ExecutorService.submit执行任务,利用返回的Future对象的get方法接收抛出的异常,然后进行处理 重写ThreadPoolExecutor.afterExecute方法,处理传递到afterExecute方法中的异常 为工作者线程设置Un...原创 2020-03-29 16:33:58 · 1574 阅读 · 0 评论 -
redis pipeline 事务到底怎么回事呢? 怎么执行的?
MULTI,EXEC,DISCARDandWATCHare the foundation of transactions in Redis.They allow the execution of a group of commands in a single step, with two important guarantees: All the commands in a tr...原创 2019-04-25 11:47:27 · 836 阅读 · 0 评论 -
优雅关机 -- springboot 优雅关机tomcat 线程池
import org.apache.catalina.connector.Connector;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;import org.spri...原创 2019-04-29 00:03:32 · 1030 阅读 · 0 评论 -
【快速工具】top cpu load最忙的前五线程 tool
top 线程分析:在机器上执行如下三个步骤即可找到最繁忙的线程信息:1 wget https://raw.githubusercontent.com/iqiancheng/fast-profiler/master/show-busy-java-threads.sh2 sudo chmod u+x show-busy-java-threads.sh3 sudo ./show-busy...原创 2019-04-26 23:15:14 · 317 阅读 · 0 评论 -
【技能库】--批量任务多线程并发执行(324)
扩展callable 接口 并且 Futrue import com.alibaba.fastjson.JSON;import com.google.common.collect.Lists;import com.google.common.util.concurrent.Uninterruptibles;import org.apache.commons.la原创 2017-09-16 14:13:04 · 1756 阅读 · 0 评论