0

I have a Spring application that starts a REST service:

    ServiceManager.startService();

When I am debugging this application in IntelliJ IDEA, however, it seems that when any thread reaches a breakpoint, not only that thread but also the service's thread is stopped. I would like to know whether I can start this service method in some way so that it continues to run when other threads stop at breakpoints.

I currently start the service as follows:

    Runnable task = () -> {
        ServiceManager.startService();
    };
    task.run();

    //breakpoint here
    doSomeStuff();

I put a breakpoint in the doSomeStuff() method, and when the debugger stops at that that line the console displays that service started successfully. If at that point I send a request to the service via postman, however, the response is not delivered until I continue execution past the breakpoint.

As far as I know, this is a concurrency problem, and I would like to know if is it possible to run my service in a different way so that the Service is not stopped when another thread reaches a breakpoint during debugging.

The method ServiceManager.startService() is an implementation to starts a simple rest endpoint using Spring Framework.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
Jorge Avila
  • 149
  • 1
  • 9
  • Which `ServiceManager` is this? Which debugger? – John Bollinger Aug 01 '18 at 15:16
  • 1
    https://stackoverflow.com/questions/8174408/does-a-breakpoint-halt-all-threads – Oleg Aug 01 '18 at 15:16
  • Note, too, that your approach to invoking `ServiceManager.startService()` is pretty convoluted. In the code as presently written, you gain nothing but obfuscation from creating a `Runnable` around that *vs*. just invoking `ServiceManager.startService()` directly. – John Bollinger Aug 01 '18 at 15:18
  • Note, third, that if you actually reach `doSomeStuff()` while the service you started is still running, then it must *already* be running in another thread, because you will not reach that point until after the `ServiceManager.startService()` invocation returns. – John Bollinger Aug 01 '18 at 15:19
  • Is your problem that `startService()` ramps up a service in the background, but the service is not yet ready when you execute `doSomeStuff()`? – VGR Aug 01 '18 at 15:36
  • @JohnBollinger, I updated info about debugger and Service. The method `startService()` it takes some seconds to be ready and completes succesfully displaying in my console the service is up, after completing this call arrives to the breakpoint placed at `doSomeStuff()` method. at this point is where I can't make requests if process is paused by debugger. so I would like to know if there is a suggestion to improve this. – Jorge Avila Aug 01 '18 at 15:37

0 Answers0