Steve McLeod
Steve McLeod

Reputation: 52458

Can Guava's AbstractExecutionThreadService be reused?

As far as I can tell, once the run() method of AbstractExecutionThreadService stops, it can't be started again. Is that correct?

I have a service that extends AbstractExecutionThreadService. In my tests I want to start this service, use it, stop it, then start it again. Any suggestions what I can/should do to achieve this while using AbstractExecutionThreadService or AbstractService?

Upvotes: 0

Views: 500

Answers (1)

ColinD
ColinD

Reputation: 110054

Service.start() states that a stopped Service may not be restarted. I'd say just create a new instance of your service and start it each time.

Upvotes: 3

Related Questions