Multi-threaded applications and multi-threaded Application Design

Source: Internet
Author: User

Multi-threaded applications and multi-threaded Application Design

 

We are used to executing some additional time-consuming operations in a single thread, or performing operations on tasks that may impede other tasks. through the rational use of multiple threads, allows the client to get a faster response. By using separate threads to execute CPU-intensive and IO-intensive jobs, the user interface remains active. Of course, everything has two sides. Improper handling will lead to thread security issues.

 

Create and use threads

We often use the new keyword to create a thread. Below are some common thread methods.

// Create thread var Thread = new thread () => Console. writeLine (); // start thread. start (); // terminate thread. abort (); # The region method is out of date // suspends the thread. suspend (); // resume the suspended thread. resume (); # The endregion method is out of date.

 

Thread attributes

Some common attributes.

// Thread priority // thread. priority // thread status // thread. threadState // thread execution status // thread. isAlive // whether it is a background thread // thread. isBackground // thread name // thread. name

 

Thread priority

The CPU allocates a longer period of time to threads with higher priority.

 

Background thread

The background thread stops immediately after the last foreground thread stops.

 

 

 

 

Https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/threading/multithreaded-applications (reference)

 

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.