using
System;
using System.Threading;
class T
... {
static int i;
static void EP()
...{
for(i=0;i<80000000;i++)
...{
if(i%10000000==0)
...{
Console.WriteLine(Thread.CurrentThread.Name+i);
Thread.Sleep(1);
}
}
}
static void Main()
...{
Thread current=Thread.CurrentThread;
current.Name="Main Thread";
ThreadStart eP=new ThreadStart(EP);
Thread sT=new Thread(eP);
sT.Name="FirstSonThread";
sT.Priority=ThreadPriority.Highest;
current.Priority=ThreadPriority.Highest;
sT.Start();
//Console.ReadLine();
EP();
}
}
using System.Threading;
class T
... {
static int i;
static void EP()
...{
for(i=0;i<80000000;i++)
...{
if(i%10000000==0)
...{
Console.WriteLine(Thread.CurrentThread.Name+i);
Thread.Sleep(1);
}
}
}
static void Main()
...{
Thread current=Thread.CurrentThread;
current.Name="Main Thread";
ThreadStart eP=new ThreadStart(EP);
Thread sT=new Thread(eP);
sT.Name="FirstSonThread";
sT.Priority=ThreadPriority.Highest;
current.Priority=ThreadPriority.Highest;
sT.Start();
//Console.ReadLine();
EP();
}
}
using
System;
using System.Threading;
class Thread_Pool
... {
static int interval;
static void Main(string[] args)
...{
Console.Write(@"Interval to display result>");
interval=int.Parse(Console.ReadLine());
ThreadPool.QueueUserWorkItem(new WaitCallback(StartMethod));
Thread.Sleep(100);
ThreadPool.QueueUserWorkItem(new WaitCallback(StartMethod));
Console.ReadLine();
}
static void StartMethod(object stateInfo)
...{
DisplayNumber("Thread"+DateTime.Now.Millisecond.ToString());
Console.WriteLine("Thread Finish!");
}
static void DisplayNumber(string givenThreadName)
...{
Console.WriteLine(@"Thread '"+givenThreadName+"' start!");
for(int i=0; i<8*interval; i++)
...{
if(i%interval==0)
...{
Console.WriteLine(givenThreadName+i);
Thread.Sleep(1000);
}
}
}
}
using System.Threading;
class Thread_Pool
... {
static int interval;
static void Main(string[] args)
...{
Console.Write(@"Interval to display result>");
interval=int.Parse(Console.ReadLine());
ThreadPool.QueueUserWorkItem(new WaitCallback(StartMethod));
Thread.Sleep(100);
ThreadPool.QueueUserWorkItem(new WaitCallback(StartMethod));
Console.ReadLine();
}
static void StartMethod(object stateInfo)
...{
DisplayNumber("Thread"+DateTime.Now.Millisecond.ToString());
Console.WriteLine("Thread Finish!");
}
static void DisplayNumber(string givenThreadName)
...{
Console.WriteLine(@"Thread '"+givenThreadName+"' start!");
for(int i=0; i<8*interval; i++)
...{
if(i%interval==0)
...{
Console.WriteLine(givenThreadName+i);
Thread.Sleep(1000);
}
}
}
}