Multithreading and scratch

Source: Internet
Author: User

Multithreading and scratch

What is a process before learning multithreading?

A process is an application running in the system.

Each process is independent, and each process runs in its dedicated and protected memory space.

You can use the "activity monitor" to view the processes enabled in Mac.

What is thread next?

To execute a task, a process must have a thread (each process only needs one main thread)

All tasks in a process are executed in the thread.

 

Thread serial

1. Serial

2. If you want to execute multiple tasks in one thread, you can only execute them one by one in order.

 

 

So what is multithreading?

1. Multiple Threads can be opened in a process, and each thread can execute different tasks in parallel.

2. multithreading technology can improve program execution efficiency

 

Multithreading Principle

1. At the same time, the CPU can only process one thread, and only one thread is working.

2. Concurrent execution of multiple threads means that the CPU is switching quickly.

3. Because CPU switching is fast, multithreading is caused (in fact, it is an illusion)

 

Advantages and disadvantages of Multithreading

Advantages:

1. Improve program execution efficiency

2. appropriately improving resource utilization

 

Disadvantages:

1. There is an overhead for creating a thread. It takes about 90 milliseconds to create a thread in iOS.

2. Enabling a large number of threads will reduce program performance.

3. Make the program design more complex

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.