|
Listing 5-9 extracted from chapter
Processes, threads and synchronization
Listing 5-8< > Listing 5-10
This listing can be compiled with the command line: csc.exe /target:exe Example_5_9.cs Errors: 0 Warnings: 0
Example_5_9.cs
using System.Collections.Generic;
using System.Collections;
public class Program {
public static void Main() {
List<int> list = new List<int>();
// ...
lock ( ( (ICollection) list ).SyncRoot ) {
foreach (int i in list) {
/* ... */
}
}
}
}
Copyright Patrick Smacchia 2006 2007
|