locked
Multiple simultaneous threads RRS feed

  • Question

  • Hi, there,

    I am trying to send out multiple requests from a client to a server simultaneously (threads starting at the same time). The server will handle each request and send the request file back to the client. I wrote the following code to do this job.

    Can the following code do this job?

    Thanks for your help.



      private void btnSocketThread_Click(object sender, System.EventArgs e)
      {

       for(int i=0; i<10; i++)
       {
        Thread t = new Thread(new ThreadStart(GetFileSocket));
        t.Start();
       }  
      
      }


     

    Monday, September 19, 2005 7:49 AM

Answers

  • Hi,

    Yes that will spawn out 10 threads and the method GetFileSocket would be called as many times on separate threads.

    Regards,

    Vikram

    Tuesday, September 20, 2005 11:53 AM
  • Hi,

    10 separate threads and the GetFileSocket() would be called once by each thread.

    Regards,
    Vikram
    Tuesday, September 20, 2005 3:40 PM

All replies

  • Hi,

    Yes that will spawn out 10 threads and the method GetFileSocket would be called as many times on separate threads.

    Regards,

    Vikram

    Tuesday, September 20, 2005 11:53 AM
  • Hi, Vikram,

    Thank you for your help.

    Do you mean there will be 10 simultaneous threads and each thread will execute GetFileSocket 10 times?

    Or, there will be 10 threads and each thread will execute GetFileSocket only once? (And this is what I want)

    Thank you and best wishes.
    Tuesday, September 20, 2005 3:15 PM
  • Hi,

    10 separate threads and the GetFileSocket() would be called once by each thread.

    Regards,
    Vikram
    Tuesday, September 20, 2005 3:40 PM
  • Vikram, thank you for your help!

    Tuesday, September 20, 2005 8:39 PM