How to implement multithreading in. Net

Source: Internet
Author: User
The thread must also be executing a piece of code. So to produce a thread, you must first write a method for the thread, which is the code that the thread runs to execute. (Find someone to do something) the method is called by a delegate when the thread starts.

(Benefits of delegation)

(When a thread starts, a delegate is invoked, and the delegate executes the appropriate method to implement the thread execution method.)

L 4 steps to generate a thread: • Write the method that produces the thread • Reference the System.Threading namespace • Instantiate the thread class and pass in a delegate that points to the method that the thread is running. (This thread has been generated, but not yet) • Call the Start method of the thread instance, marking that the thread can be executed by the CPU, but the execution time is determined by the CPU. L Foreground thread: only all foreground threads are closed to complete the program shutdown. L Background thread: As long as all foreground threads end, the background thread ends automatically. Lstart () Start thread labort () terminates thread lthread.sleep (1) static method, which allows the current thread to stop running for a period of time lname thread name Lthread.currentthread get current thread reference

How to implement multithreading in. Net

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.