Threads ( how to create 100 threads and more at a time)?

asp.net Brazil
  • 12 years ago

    HI Good Morning, This is shavil, i have doubt on threads using c#,First i created a table in sql server in which one of the field is "PROCESSOR ID" which is primary key. with the help of the PROCESSOR ID I want to create a thread in frent end .suposse if there are 100 Processores ID or (may be more )means i want create 100 threads like.But iam not able to create 100 Threads at a time.. ex: Thread t1 = new thread(); i can't create 100 thread like t2,t3,.... so what my Question is how should i keep the loop for the threads.. and we can increase threads automatically. tomorrow clients requriment may be 1000 threads then ican't able to add... so if any body have idea means please reply as soon as possible Thanks & Regards Shavil S Forward Message

  • 12 years ago

    Hi,

    I dont think you would be able to create that many threads anyway.

    From what i know, IIS app pools have a thread setting (Web Garden) which limits the amounts of threads that can be created, so i doubt you could get 1000 threads going at once.

    Secondly, at once is quite a complex term, it would take time to loop through and create 1000 threads, so some threads may have finished before all 1000 are created.

    It sounds like a strange site you are building, what is it you are trying to achieve?  Do you need to use that many threads?

    Regards

    Simon C

  • 12 years ago

     It is not a very big application.Whats my task i have to create a thread for every processor Id .ok let it be think there are 25 processors id then how should i create 25 threads which are running independently..........

                Can u send me the answer as soon as possible...

     Thanks & Regards
     Shavil S

  • 12 years ago

    It is not a very big application.Whats my task i have to create a thread for every processor Id .ok let it be think there are 25 processors id then how should i create 25 threads which are running independently..........

                Can u send me the answer as soon as possible...

     Thanks & Regards
     Shavil S

  • 12 years ago

    Hi,

    You should be able to create a thread as you would do normally, i am just not sure how IIS will respond to them if there are more than the allowed limit in the web garden.

    Do you know how to create a thread?

    Si

  • 11 years ago
    Jose, a thread is executed by the processor just for a few milliseconds. If you create 100 or more threads the processor will execute one by one just for a few milliseconds each one. There will be no gain in creating so many threads just like you want. What you need is to use a Queue with a Thread Pool. Search in google (or other search engine) for C# Thread Pool

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Owning a computer without programming is like having a kitchen and using only the microwave oven” - Charles Petzold