반응형
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace test_thread
{
class Program
{
static void Main(string[] args)
{
new Program();
}
public Program() {
new Thread(new ThreadStart(Thread_Test1)).Start();
new Thread(new ThreadStart(Thread_Test2)).Start();
}
public void Thread_Test1() {
int i = 0;
while(true) {
Console.WriteLine("Thread_Test1 i = {0}", i++);
Thread.Sleep((1000));
}
}
public void Thread_Test2() {
int i = 0;
while(true) {
Console.WriteLine("Thread_Test2 i = {0}", i++);
Thread.Sleep(2500);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace test_thread
{
class Program
{
static void Main(string[] args)
{
new Program();
}
String Commander;
Thread _thread;
public Program() {
_thread = new Thread(new ThreadStart(Thread_Test1));
_thread.Start();
while(true) {
Commander = Console.ReadLine();
if(Commander == "exit") {
_thread.Abort();
break;
}
}
Console.WriteLine("");
}
public void Thread_Test1() {
int i = 0;
while(true) {
Console.WriteLine((i++).ToString());
Thread.Sleep(1000);
}
}
}
}
'sssss' 는 내가 임의로 입력한 것
반응형
'▩▩ 프로그래밍 ▩▩ > C#' 카테고리의 다른 글
| [C#] 이미지 <-> byte[] (0) | 2013.06.26 |
|---|---|
| [GMap] 도구상자에 GMap 컨트롤 추가 (2) | 2013.05.30 |
| [C#] byte[] 를 구조체로 바꾸기 (0) | 2013.04.18 |
| [C#] 폼 x버튼 누를 때, 폼 종료시 (1) | 2013.04.01 |
| [C#] 텍스트박스(TextBox)에서 엔터(Enter)쳐서 이벤트 실행할 때 (0) | 2013.03.27 |
| [C#] 폼 크기 조절 못하게하기 (2) | 2013.03.27 |
| [C#] 스레드(thread) 사용 시 매개변수 넘기기 (delegate) (0) | 2013.03.27 |
| [C#] 스레드풀, ThreadPool (3) | 2013.03.14 |
![[나크21] 캐주얼 미니스커트 치마바지 NK21-P-10](https://image13.coupangcdn.com/image/affiliate/banner/a0874210c3b8ced08e8de1985ebfb8c9@2x.jpg)

