I have problem in multitasking. I have explained in below.
-
I need to do some process for all users(for instance 200 users) in my
web app. -
The process is protocol request call.
-
I can able to run up to 1000 users with sleep time between thread creation.
but I need to run without sleep time and also i need to run up to 1000 users. -
When I try to run for 200 users I am not getting any response. Its stopped for long time. I don’t know the reason.
Please let me know If anybody have idea to resolve it
…Thanks…
Well, It sounds to me like it’s an issue with creating too many threads too quickly.
Try using some kind of ThreadPool to minimize the overhead of thread creation. Basically you’re going to want to have a fixed set of threads that are created, and then re-use those threads for new tasks instead of making a new thread for each task.
If, for example, each task takes 1s to run and you get 2 tasks per second for 100 seconds, the thread-per-task method would create 200 threads to run all tasks. A pool of 100 threads would be able to execute all 200 tasks using some of those threads more than once and never leaving anything waiting/sleeping.