Thread of C #

Source: Internet
Author: User

1. Thread is used for a multithreaded implementation of a program, that is, multiple tasks can be done simultaneously; thread can also be used to do other work while waiting for a task to complete

2. In a single-core case, multitasking is slower than one, while multitasking is done in sequential order with each thread for a short period of time

3. The sleep method is to let the thread stop the corresponding time, such as Thread1.sleep (1000) is to stop for 1 seconds, while the death there are two, one is the completion of the natural end of the task, and the second is to execute the active kill thread:

--use Thread.Interrupt () method, ask the Thread to kill itself.

4. Mechanisms for synchronizing between several threads: 1.the Interlock class 2.The C # lock statement 3.The Monitor class

5. Avoid meaningless consumption caused by deadlocks

Thread of C #

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.