using System;
using System.Threading;
class ThreadTest
{
static void Main()
{
Thread t = new Thread(WriteY); // Kick off a new thread
t.Start(); // running WriteY()
// Simultaneously, do something on the main thread.
for (int i = 0; i < 10; i++)
Console.Write ("x");
}
static void WriteY()
{
for (int i = 0; i < 10; i++)
Console.Write("y");
}
}
The output:
yyyyyyyyyyxxxxxxxxxx
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |