1
Reply

Write A program To Print "INDIA" "CHINA" "INDIA",CHINA using Two Threads in C#

Kamal Pal

Kamal Pal

12y
1.3k
0
Reply

    using System; using System.Collections.Generic; using System.Text;\using System.Threading.Tasks; using System.Threading; namespace Print_Message {class Program{public void firstMessage(){for (int i = 0; i < 2; i++) {Console.WriteLine("INDIA");Thread.Sleep(1000);}}public void secondMessage(){for (int j = 0; j < 2; j++){Console.WriteLine("CHINA");Thread.Sleep(1000);}}static void Main(string[] args){Program prg = new Program();ThreadStart thread_start1 = new ThreadStart(prg.firstMessage);Thread thread1 = new Thread(thread_start1);thread1.Start();Thread.Sleep(500);ThreadStart thraed_start2 = new ThreadStart(prg.secondMessage);Thread thread2 = new Thread(thraed_start2); thread2.Start(); Console.ReadLine();}} }