using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using
System.Threading;namespace
{
threadingpublic partial class ThreadWork : Form{
{
{
}
}
{
myThread.Start();
{
}
public static void DoWork()for (int i = 0; i < 3; i++)Console.WriteLine("Working thread...");Thread.Sleep(100);private void Form1_Load(object sender, EventArgs e)ThreadStart myThreadDelegate = new ThreadStart(DoWork);Thread myThread = new Thread(myThreadDelegate);for (int i = 0; i < 3; i++)Console.WriteLine("In main.");Thread.Sleep(100);//var stopwatch = Stopwatch.StartNew();
// Create an array of Thread references.
{
Thread[] array = new Thread[4];for (int i = 0; i < array.Length; i++)// Start the thread with a ThreadStart.array[i] =
array[i].Start();
}
new Thread(new ThreadStart(DoWork));// Join all the threads.
{
array[i].Join();
}
{
array1[i] =
array1[i].Join();
}
}
{
System.Threading.
for (int i = 0; i < array.Length; i++)Thread[] array1 = new Thread[4];for (int i = 0; i < array1.Length; i++)new Thread(new ThreadStart(DoWork));public void start()ThreadStart Th = new ThreadStart(DoWork);Thread one = new Thread(Th);// To Start the thread one.Start();
// To Suspend the Thread for the priori period
Thread.Sleep(100);// To Set Thread Name one.Name =
"mano";// To Suspend a Thread one.Suspend();
// To Resume the Supsended thread one.Resume();
// Normal ,Above Norma, Below Norma ,Highest ,Lowest one.Priority =
one.Start();
ThreadPriority.AboveNormal;// To Terminate the thread one.Abort();
one.Join();
}
{
}
}
}public void ThreadSynchronization()
System.Threading;namespace
{
threadingpublic partial class ThreadWork : Form{
{
{
}
}
{
myThread.Start();
{
}
public static void DoWork()for (int i = 0; i < 3; i++)Console.WriteLine("Working thread...");Thread.Sleep(100);private void Form1_Load(object sender, EventArgs e)ThreadStart myThreadDelegate = new ThreadStart(DoWork);Thread myThread = new Thread(myThreadDelegate);for (int i = 0; i < 3; i++)Console.WriteLine("In main.");Thread.Sleep(100);//var stopwatch = Stopwatch.StartNew();
// Create an array of Thread references.
{
Thread[] array = new Thread[4];for (int i = 0; i < array.Length; i++)// Start the thread with a ThreadStart.array[i] =
array[i].Start();
}
new Thread(new ThreadStart(DoWork));// Join all the threads.
{
array[i].Join();
}
{
array1[i] =
array1[i].Join();
}
}
{
System.Threading.
for (int i = 0; i < array.Length; i++)Thread[] array1 = new Thread[4];for (int i = 0; i < array1.Length; i++)new Thread(new ThreadStart(DoWork));public void start()ThreadStart Th = new ThreadStart(DoWork);Thread one = new Thread(Th);// To Start the thread one.Start();
// To Suspend the Thread for the priori period
Thread.Sleep(100);// To Set Thread Name one.Name =
"mano";// To Suspend a Thread one.Suspend();
// To Resume the Supsended thread one.Resume();
// Normal ,Above Norma, Below Norma ,Highest ,Lowest one.Priority =
one.Start();
ThreadPriority.AboveNormal;// To Terminate the thread one.Abort();
one.Join();
}
{
}
}
}public void ThreadSynchronization()
Comments
Post a Comment