Nếu bạn muốn làm việc với một ví dụ thực tế hơn, hãy xem các ví dụ từ nhóm song song, bạn sẽ tìm thấy ray tracing tuyệt vời và các ví dụ liên quan đến toán học khác. Lưu ý rằng gọi () sẽ liên quan đến một chuyển ngữ cảnh (một hoạt động đắt tiền cho CPU), vì vậy nó có thể làm chậm các ứng dụng mẫu xuống nhiều hơn so với thực hiện công việc có thể có. | CHAPTER 5 PARALLELIZATION AND THREADING ENHANCEMENTS factorials or walk trees of data but I think this distracts at least initially from understanding the basics. If you want to work with a more realistic example take a look at the examples from the parallel team you will find excellent ray tracing and other math related examples. Note that calling the method will involve a context switch an expensive operation for the CPU so it might slow the sample application down more than performing work might have. 1. Create a new console application called add the following using directives using using 2. Amend to the following code class Program . . public static List StockQuote Stocks new List StockQuote static void Main string args . double serialSeconds 0 double parallelSeconds 0 Stopwatch sw new Stopwatch PopulateStockList sw RunInSerial serialSeconds sw RunInParallel parallelSeconds Finished serial at 0 and took 1 serialSeconds Finished parallel at 0 and took 1 parallelSeconds private static void PopulateStockList new StockQuote ID 1 new StockQuote ID 2 new StockQuote ID 3 new StockQuote ID 4 new StockQuote ID 5 new StockQuote ID 6 Company Microsoft Price Company IBM Price Company Yahoo Price Company Google Price Company Altavista Price Company Ask Price 102 CHAPTER 5 PARALLELIZATION AND THREADING ENHANCEMENTS new StockQuote ID 7 Company Amazon Price new StockQuote ID 8 Company HSBC Price new StockQuote ID 9 Company Barclays Price new StockQuote ID 10 Company Gilette Price private static void RunInSerial for int i 0 i i 7 . . .