[C # threading handbook] One of the Notes: Threading in. net

Source: Internet
Author: User

I read C # threading handbook for less business trips a few days ago, and I still feel a lot of GAINS. Now I want to write my own experiences and see better comments.
This book covers a wide range of content. I only want to write something that I think is important but I didn't know before.

1. Thread Lifecycle
The system. Threading. Thread class provides the start, stop, suspend, resume, join, and abort thread methods. You can view the thread status through the system. Threading. threadstate attribute.

TheSuspend ()Method will suspend the current thread indefinitely until another thread wakes it up.
The effect of calling join () method is that the thread will be blocked until either the other thread completes or the time period elapses, whichever occurs first.
TheAbort ()Method wocould be very useful, if you want to terminate the thread for whatever reason.

2. Suitable and unsuitable thread locations
suitable for thread use:
. background processes
the first opportunity to spawn a new thread occurs when your application needs to run a large process in the background while still keeping its user interface active and usable.
B. accessing external resources
The second circumstance in which you might want to consider spawning a new thread occurs when you are accessing resources that are not local to your system.
not suitable for multithreading:
the first is an instance where execution order is extremely important, and the second is a mistake seen quite often in code-creating new threads in a loop.

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.