Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to make a thread with for loop the loop count 1 to 10 but the teacher want to run like a Timer or Cricket Score border table

What I have tried:

C#
using System.Threading;
using System;
using System.IO;
namespace ThreadingDemo
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("F1           F2              F3");
            Thread thread1 = new Thread(Method1);
            Thread thread2 = new Thread(Method2);
            Thread thread3 = new Thread(Method3);
            thread1.Start();
            thread2.Start();
            thread3.Start();
            Console.Read();
        }
        public static void Method1()
        {
            
            
                for (int i = 1; i < 10; i++)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine("F1 " + i);


                }
            
        }
        static void Method2()
        {
            for (int i = 1; i < 10; i++)
            {
                Thread.Sleep(2000); 
                Console.WriteLine("             F2 " + i);

            }

        }
        static void Method3()
        {
            for (int i = 1; i < 10; i++)
            {
                Thread.Sleep(3000);
                Console.WriteLine("                            F3 " + i);

            }
           
           
        }
    }
}
Posted
Updated 15-Dec-21 5:05am
v2
Comments
[no name] 15-Dec-21 12:07pm    
So you want someone to have a chat with your teacher?
Dave Kreskowiak 15-Dec-21 15:48pm    
What does "run like a Timer or Cricket Score border table" supposed to mean? That makes no sense. Perhaps an example of what the output should look like is in order?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900