当前位置:网站首页>Advanced API (multithreading)
Advanced API (multithreading)
2022-07-03 07:01:00 【Bugxiu_ fu】
Not all programming languages support multithreading
Multithreading is actually equivalent to a robot ( Automatically handle things )
A few key words
1. multitasking
Self righteous to deal with multiple things at the same time
2. Program
Still , Example ---QQ installation is complete
3. process
Dynamic , When the program is opened by double clicking , The process will appear .
4. Threads
A thread is an execution unit path in a process .( The process of doing something )
summary :
A program has one or more processes
A process has at least one thread or multiple threads .
Program closed --- The process will shut down
Thread shutdown --- The process will not shut down
1. One Java The program has at least 2 Threads Customize
(1) The main thread --- effect --- Perform the operation
(2)gc Threads --- effect --- Recycling waste
The core of multithreading : Automatically complete things .
Multithreading comes from lang package
Multithreaded objects :Thread
stay Java There are ways to implement multithreading in the program 2 Kind of
1. Inherit Thread
rewrite run Method
Custom thread inheritance Thread after , If you want to implement some operations -- Must be in the run Method to perform these so-called operations .
2. Realization Runnable Interface
Custom class implementation Runnable Interface must override all abstract methods in the interface
implements Runnable{
@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println(i+"---- Custom thread "+Thread.currentThread().getName());
}
}
matters needing attention : If the thread is implemented Runnable Interface To open, you must use Thread Class call start.
MyF mf = new MyF();
Thread t = new Thread(mf);
t.setPriority(10);// Priority
t.start();// Start the custom thread manually
边栏推荐
- 每日刷题记录 (十一)
- The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?
- The 10000 hour rule won't make you a master programmer, but at least it's a good starting point
- [LeetCode]404. 左叶子之和
- C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
- CentOS php7.3 installing redis extensions
- Notes on the core knowledge of Domain Driven Design DDD
- Laravel Web Framework
- 10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
- Personally design a highly concurrent seckill system
猜你喜欢
New knowledge! The virtual machine network card causes your DNS resolution to slow down
HMS core helps baby bus show high-quality children's digital content to global developers
如何迁移或复制VMware虚拟机系统
卡特兰数(Catalan)的应用场景
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
How to migrate or replicate VMware virtual machine systems
Winter vacation work of software engineering practice
Golang operation redis: write and read kV data
2022年华东师范大学计科考研复试机试题-详细题解
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
随机推荐
Practical plug-ins in idea
Jenkins
2022年华东师范大学计科考研复试机试题-详细题解
POI excel percentage
crontab定时任务
Class and object summary
修改MySQL密码
2021 year end summary
My 2020 summary "don't love the past, indulge in moving forward"
UTC time, GMT time, CST time
卡特兰数(Catalan)的应用场景
Summary of UI module design and practical application of agent mode
机械观和系统观的科学思维方式各有什么特点和作用
Win 10 find the port and close the port
RestHighLevelClient获取某个索引的mapping
Reading notes of "learn to ask questions"
PHP install composer
JUC forkjoinpool branch merge framework - work theft
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
【code】if (list != null && list.size() > 0)优化,集合判空实现方式