同步线程和同步代码块 [英] Synchronization thread and synchronized block of code

查看:112
本文介绍了同步线程和同步代码块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是同步线程和同步代码块?

what is Synchronization thread and synchronized block of code?

推荐答案

没有这样的术语.有线程同步.这是一个很好的起点: http://en.wikipedia.org/wiki/Synchronization_(computer_science) [ ^ ].这是.NET的线程教程: http://msdn.microsoft. com/en-us/library/aa645740(v = vs.71).aspx [ http: //msdn.microsoft.com/zh-CN/library/c5kehkcz.aspx [ http://en.wikipedia .org/wiki/Critical_section [ ^ ]), System.Threading.Mutex( http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx [ ^ ]),或更一般地,是System.Threading.SemaphoreSystem.Threading.SemaphoreSlim( ^ ], http: //msdn.microsoft.com/zh-CN/library/system.threading.semaphoreslim.aspx [ http://msdn.microsoft.com/zh-cn/library/system.threading.monitor.aspx [ http://msdn.microsoft .com/en-us/library/system.threading.readerwriterlockslim.aspx [ ^ ]),System.Threading.ReaderWriterLock是v.2.0的类似版本(http://msdn.microsoft.com/zh-cn/library/system.threading.readerwriterlock.aspx [ http://msdn.microsoft. com/en-us/library/system.threading.readerwriterlock.aspx [ ^ ]).

—SA
There is not such terms. There is thread synchronization. This is a good point to start: http://en.wikipedia.org/wiki/Synchronization_(computer_science)[^]. This is a threading tutorial for .NET: http://msdn.microsoft.com/en-us/library/aa645740(v=vs.71).aspx[^] — 7 years old but not obsolete.

Synchronized block of code is also not a strict or definitive term, I think. A block of code can be a subject to mutual exclusive execution, which is achieved using lock statement (http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx[^]) which is equivalent to Critical Section (http://en.wikipedia.org/wiki/Critical_section[^]), System.Threading.Mutex (http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx[^]) or, more generally, a System.Threading.Semaphore and System.Threading.SemaphoreSlim (http://msdn.microsoft.com/en-us/library/system.threading.semaphore.aspx[^], http://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim.aspx[^]); more advanced data synchronization instrument is System.Threading.Monitor (http://msdn.microsoft.com/en-us/library/system.threading.monitor.aspx[^]). A very useful generalization of the lock is the System.Threading.ReaderWriterLockSlim (http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim.aspx[^]), System.Threading.ReaderWriterLock is the analog of it for v.2.0 (http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlock.aspx[^]).

I listed only the most important primitives from System.Threading (http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlock.aspx[^]).

—SA


这篇关于同步线程和同步代码块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆