本文介绍了线程和线程池的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道什么线程和线程池吗?我们如何同步线程?

Does anyone knows what threads and thread pool is? How can we  synchronise threads?

推荐答案

SemaphoreSlim,互斥量,ReaderWriterLockSlim或Monitor

SemaphoreSlim, Mutex, ReaderWriterLockSlim or Monitor

但是要实现多线程应用程序,您必须了解所有工作原理并充分理解它,尤其是在共享内存空间中共享对象(例如数据库或静态变量)的情况下.如果您不首先了解这些内容,那么 您将最终得到非常复杂的代码,这些代码由于围绕多线程环境中共享资源的访问的活锁,死锁和网格锁问题而被锁定,无法被解锁.希望对您有所帮助.

but to implement a multi-threaded application you MUST understand how all this works and understand it well, especially if you are sharing objects in a shared memory space (like a database or static variables). If you do not understand this stuff first then you will end up with really complicated code that locks and cannot be unlocked due to livelock and deadlock and gridlock issues surrounding the access of a shared resource in a multi-threaded environment. I hope this helps.


这篇关于线程和线程池的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-01 01:03