0

I am doing remote debugging using eclipse. My requirement is to make 20 requests at the same time, stopping at one point using debug breakpoint and then release all the suspended threads at the same time to test how code is behaving when multiple threads access the code at same time. However, when I tried this I found only one thread is serving all the request Daemon Thread [http-0.0.0.0-8080-Processor60] (Suspended (breakpoint at line 440 in VcsInfoDAO))

when first request completes, then only second request comes to the breakpoint serving by the same thread mentioned above. Is there any setting in eclipse to make it all the request comes to a single point and then in some way to release the threads at the same time so that all the threads access the code thereafter at the same time.

Any help would be highly appreciated.

Sourabh

1 Answer 1

0

Eclipse has nothing to do with what you see. If you set a breakpoint to some place inside a method supposed to be called concurrently, and if your client code really launches 20 concurrent requests, and if you observe that the second request is only handled once the first one has finished, then what you thought was concurrent is not.

I see two possible explanations:

  • you have a unique thread handling all the requests. If several are sent concurrently, all the requests are queued and handled one by one
  • you have several threads handling the request concurrently, but the client code sends 20 requests sequentially, rather than sending 20 requests concurrently.

Anyway, using a breakpoint to test such a thing is not a good solution. You'll have to hit the "Continue (F8)" button for each of the 20 threads, thus they won't restart at the same time. You'd bette use a CountDownLatch initialized at 20 to do that:

private CountDownLatch latch = new CountDownLatch(20);

public void run() {
    // some code
    // here we want to pause all 20 threads and restart them all at the same time
    latch.countDown(); // The 20th thread will open the barrier, and they will all restart at the same time
    latch.await();
}
Sign up to request clarification or add additional context in comments.

1 Comment

The box that I am debugging is Production box which is supposed to handle multiple request at the same time. On debugging it remotely using eclipse, when I put debug point and hit it 10 times. Now my requirement is to stop all request at that point and on releasing the flow, all should go at the same time. But in my case even I it hit the server 10 times, I am getting flows one by one only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.