简体   繁体   中英

How to prevent a thread from switching?

I have a simple question about multithreading.

I want a thread in the application to finish its task before it switches to thead from the same application?

I know it will switch with other threads from other applications. However, is it possible for thread to keep control and not switch with others threads originating from the same application?

唯一的方法是阻塞其他线程,直到您要完成的线程解除阻塞为止,请使用ManualResetEventSlimAutoResetEventSemaphoreSlim类的同步机制来控制线程的流。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM