当前位置:网站首页>[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 .

边栏推荐
- Kunlunbase meetup is waiting for you!
- How does unity fixedupdate call at a fixed frame rate
- Animation_ IK overview
- [K & R] Chinese Second Edition personal questions Chapter1
- Golang string segmentation, substitution and interception
- Unity editor expansion - scrolling list
- Osgearth target selection
- 【K&R】中文第二版 个人题解 Chapter1
- Delete the last character of the string in golang
- P1596 [USACO10OCT]Lake Counting S
猜你喜欢

Constraintlayout's constraintset dynamically modifies constraints

Notes on understanding applets 2022/7/3

Graphics_ Games101/202 learning notes

Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation

Kwai 20200412 recruitment

Basic operation and process control

Unity learning notes

Unity interactive water ripple post-treatment

Simply start with the essence and principle of SOM neural network

Dotween plug-in
随机推荐
Osgearth topographic shading map drawing
Unity editor expansion - window, sub window, menu, right-click menu (context menu)
producer consumer problem
Delete the last character of the string in golang
2021-10-19
Pit & ADB wireless debugging of vivo real machine debugging
【K&R】中文第二版 个人题解 Chapter1
单调栈-503. 下一个更大元素 II
Golang 字符串分割,替换和截取
Initial unity
【Rust 笔记】09-特型与泛型
Some understandings of 3dfiles
Introduction to Base64 coding
Find the intersection of line segments
Campus lost and found platform based on SSM, source code, database script, project import and operation video tutorial, Thesis Writing Tutorial
【Rust笔记】06-包和模块
jupyter远程服务器配置以及服务器开机自启
UE4 call DLL
[K & R] Chinese Second Edition personal questions Chapter1
Why can void * be a general pointer