아래 예제는 Thread를 간단하게 시작하는 방법을 사용한 것이다.
단 한줄로 Thread를 시작한다.
using System;
using System.Threading;
namespace ThreadTest
{
class Program
{
static void Main(string[] args)
{
new Thread(Go).Start(); // Call Go() on a new thread
Go(); // Call Go() on the main thread
}
static void Go()
{
for (int i = 0; i < 5; i++)
Console.WriteLine(i);
}
}
}
아래는 실행 결과 화면이다.
단 한줄로 Thread를 시작한다.
using System;
using System.Threading;
namespace ThreadTest
{
class Program
{
static void Main(string[] args)
{
new Thread(Go).Start(); // Call Go() on a new thread
Go(); // Call Go() on the main thread
}
static void Go()
{
for (int i = 0; i < 5; i++)
Console.WriteLine(i);
}
}
}
아래는 실행 결과 화면이다.
'Code > C#' 카테고리의 다른 글
| static field를 사용한 Thread (0) | 2007.12.09 |
|---|---|
| Thread에서 공동의 인스턴스 사용 예제 (0) | 2007.12.09 |
| Thread Join 사용법과 예제 (0) | 2007.12.08 |
| Thread Abort 사용법과 예제 (0) | 2007.12.08 |
| Thread & Lock 사용법과 예제 (0) | 2007.12.08 |