using System; using System.Threading; public class List1_2 { public static void Main() { ThreadedTextPrinter printer = new ThreadedTextPrinter(); // @ printer.Print("A"); // A for (int i = 0; i < 100; i++) { Thread.Sleep(5); Console.Write(" B "); } } } public class ThreadedTextPrinter // B { private string text; public void Print(string s) // C { text = s; // D Thread thread = new Thread(new ThreadStart(ThreadMethod)); thread.Start(); } // 別スレッドで動作させるメソッド private void ThreadMethod() // E { for (int i = 0; i < 100; i++) { Thread.Sleep(5); Console.Write(" {0} ", text); // F } } }