티스토리 뷰
Thread 간에 서로 얼마자 자주 interupt 가 일어나는지를 알 수 있는 샘플 코드이다.
두개의 thread가 화면에 점과 대쉬를 표시한다.
결과 화면을 보면 인터럽트의 정도를 확인할 수 있다.
두개의 thread가 화면에 점과 대쉬를 표시한다.
결과 화면을 보면 인터럽트의 정도를 확인할 수 있다.
using System;
using System.Threading;
namespace ThreadSample
{
class Program
{
public const int Repetitions = 1000;
static void Main(string[] args)
{
ThreadStart myThreadStart = new ThreadStart(DoWork);
Thread myThread = new Thread(myThreadStart);
myThread.Start();
for (int count = 0; count < Repetitions; count++)
{
Console.Write('-');
}
myThread.Join();
}
public static void DoWork()
{
for (int count = 0; count < Repetitions; count++)
{
Console.Write('.');
}
}
}
}
using System.Threading;
namespace ThreadSample
{
class Program
{
public const int Repetitions = 1000;
static void Main(string[] args)
{
ThreadStart myThreadStart = new ThreadStart(DoWork);
Thread myThread = new Thread(myThreadStart);
myThread.Start();
for (int count = 0; count < Repetitions; count++)
{
Console.Write('-');
}
myThread.Join();
}
public static void DoWork()
{
for (int count = 0; count < Repetitions; count++)
{
Console.Write('.');
}
}
}
}
'Code > C#' 카테고리의 다른 글
Thread & Monitor 사용 방법과 예제 (0) | 2007.12.08 |
---|---|
[C#] C# 2.0 스타일 Thread 사용법과 예제 (0) | 2007.12.08 |
[C#] Thread & FileStream 사용 예제 (0) | 2007.12.07 |
[C#] Thread 샘플 코드 3 (0) | 2007.12.07 |
[C#] Thread 샘플 코드 2 (0) | 2007.12.07 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- .net framework
- AxWebBrowser
- WinAutomation
- Service pack
- READYSTATE_COMPLETE
- Rollback Rx
- 애드센스숨기기
- 스크린캡쳐
- jre
- AdSense감추기
- AdSense숨기기
- iTextSharp
- download.com
- registry
- 유틸리티
- 애드센스감추기
- Sample Code
- Automation
- iText
- Microsoft
- ScreenHunter
- DotNetMagic
- tagREADYSTATE
- Phalanger
- java
- Regular Expressions
- windows
- c#
- autohotkey
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함