当前位置:网站首页>[concurrent programming] concurrent tool class of thread
[concurrent programming] concurrent tool class of thread
2022-07-03 08:32:00 【keeper42】
Fork-Join
Divide and conquer algorithm ( Divide and rule )
The scale is N The problem of ,N< threshold , Direct solution ,N> threshold , take N Decompose into K A small mold problem , The subproblems are independent of each other , The same form as the original problem , The solutions of the subproblem are combined to obtain the solution of the original problem
Dynamic specifications
Working secret
workStealing
Fork/Join The standard paradigm used
Common concurrent tool classes
CountDownLatch
effect : It is a group of threads that wait for other threads to complete their work before executing , Enhanced Edition join
await To wait for (join),countDown Take charge of the subtraction of the counter
CyclicBarrier
Let a group of threads reach a barrier , Blocked , Until the last thread in the group reaches the barrier , The barrier is open , All blocked threads will continue to run CyclicBarrier(int parties)
await It can be used repeatedly
CyclicBarrier(int parties, Runnable barrierAction), The barrier is open ,barrierAction The defined task will execute
CountDownLatch and CyclicBarrier Differentiation and analysis
1、countdownlatch Controlled by the third party ,CyclicBarrier Release is controlled by a set of threads themselves
2、countdownlatch Release conditions >= Number of threads ,CyclicBarrier Release conditions = Number of threads
Semaphore
Control the number of threads accessing a specific resource at the same time , Used in flow control
useful.acquire(); synchronized (pool) { conn = pool.removeFirst(); } useless.release(); |
Exchange
Data exchange between two threads
Callable、Future and FutureTask
isDone, end , Normal or abnormal end , Or cancel it yourself , return true;
isCancelled The task was canceled before it was completed , return true;
cancel(boolean):
- The task hasn't started yet , return false
- The mission has started ,cancel(true), Interrupt a running task , Interrupt success , return true,cancel(false), Don't interrupt the running tasks
- The task is over , return false
Processing of documents containing pictures and words : picture ( On the cloud ), It can be used future Go get the picture , The main thread continues to parse the text .
边栏推荐
- Visual Studio (VS) shortcut keys
- Image processing 8-cnn image classification
- Huawei interview summary during the epidemic
- Base64和Base64URL
- Installation of PHP FPM software +openresty cache construction
- Unity Editor Extension - event handling
- Intersectionpicker in osgearth
- VIM learning notes from introduction to silk skating
- Minimap plug-in
- Graphics_ Learnopongl learning notes
猜你喜欢
Scite change background color
Animation_ IK overview
十六进制编码简介
jupyter远程服务器配置以及服务器开机自启
Visual Studio (VS) shortcut keys
Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
GIS实战应用案例100篇(七十八)-多规合一数据库设计及数据入库
Advanced OSG collision detection
Base64编码简介
matlab神經網絡所有傳遞函數(激活函數)公式詳解
随机推荐
UE4 call DLL
Image processing 8-cnn image classification
数据分析练习题
[K & R] Chinese Second Edition personal questions Chapter1
Osgearth north arrow display
About Wireshark's unsuccessful installation of npcap
Basic operation and process control 2
Redis cluster series 4
【Rust 笔记】10-操作符重载
Vscode, idea, VIM development tool shortcut keys
Downward compatibility and upward compatibility
Go resolve ID card
【云原生】微服务之Feign的介绍与使用
ArrayList
Golang url的编码和解码
Golang 字符串分割,替换和截取
LinkList
Pit & ADB wireless debugging of vivo real machine debugging
Mxone Pro adaptive 2.0 film and television template watermelon video theme apple cmsv10 template
Collection interface