for (int i = 0; i < 100; ++i) { ThreadPool.QueueUserWorkItem(delegate { Console.WriteLine(i); }); }Keep that answer in your head! Now...what do you expect the output of the following?
int i; for (i = 0; i < 100; ++i) { ThreadPool.QueueUserWorkItem(delegate { Console.WriteLine(i); }); }Were your answers the same? Different? Why?
No comments:
Post a Comment