对于java这样的:
public synchronized void Run()
{
// function body
}------------>>> C# code:
public class C
{
public void Run()
{
lock(this)
{
// function body
}
}
public static void Main(sting[] args) {}
}
public synchronized void Run()
{
// function body
}------------>>> C# code:
public class C
{
public void Run()
{
lock(this)
{
// function body
}
}
public static void Main(sting[] args) {}
}
[C#]
Queue myCollection = new Queue();
lock( myCollection.SyncRoot ) {
foreach ( Object item in myCollection ) {
// Insert your code here.
}
}