Context: I'm writing an app in Java to loadtest a mooc webservice. I know other tools already exist but I need detailed report for each of my custom scenarios and it seems easier to generate them from my own app. In short, every thing is timed and I'm drawing graphs with things like: time until connection accepted, or response-time, etc. I need the number to be accurate (in proportions to each other).
Problem: I can start each connection in a new thread and run a scenario per thread. The drawback is that the number of threads is limited on my machine. So I need a better alternative.
Question: What can I do to start and run more connections than the allowed number of threads on my machine without using another machine ?
Idea I had: I could start and run every connection from a single thread. The thread would have a queue of actions to execute, and each time a method-call returns from the webservice, the callback would push a new event in the event queue. See pseudo code below.
Question: Would this idea induce a synchronization cost too high to have a proper response-time gaph ?
Code for What I have:
// simplified app code (omitting time measurement)
for each scenario
    start a new thread to run the scenario
// simplified scenario code (omitting time measurement)
repeat    
    start a method call
    wait until method response
// simplified callback code (omitting time measurement)
on response:
    notify scenario
Code for my idea:
// simpified app code (omitting time measurement)
repeat
    wait if actionQueue it empty
    otherwise pop first action   
    execute first action //could be a method call
// simplified callback code (omitting time measurement)
on response:
    given id of scenario that called the method
    push next action for this scenario into actionQueue
 
     
    