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

边栏推荐
- [linear table] basic operation of bidirectional linked list specify node exchange
- Golang json格式和结构体相互转换
- 详解sizeof、strlen、指针和数组等组合题
- Osgearth target selection
- Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
- 数据库原理期末复习
- Unity multi open script
- 【Rust笔记】06-包和模块
- KunlunBase MeetUP 等您来!
- Student educational administration management system of C # curriculum design
猜你喜欢

Unity4.3.1 engine source code compilation process

Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données

Mall management system of database application technology course design

KunlunBase MeetUP 等您来!

UE4 source code reading_ Bone model and animation system_ Animation process
![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)
P1596 [USACO10OCT]Lake Counting S

C#课程设计之学生教务管理系统

Scite change background color

Simple demo of solving BP neural network by gradient descent method
随机推荐
Unity change default editor
Redis cluster series 4
Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
matlab神經網絡所有傳遞函數(激活函數)公式詳解
Markdown learning
Pit & ADB wireless debugging of vivo real machine debugging
Base64编码简介
Unity Editor Extension - Outline
Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
Unity editor expansion - the framework and context of unity imgui
Intersectionpicker in osgearth
Simple demo of solving BP neural network by gradient descent method
OpenGL learning notes
Sequence of map implementation classes
LinkedList set
KunlunBase MeetUP 等您来!
Osgearth topographic shading map drawing
Golang string segmentation, substitution and interception
Golang中删除字符串的最后一个字符
swagger文档配置