JAVAFX Service creates new threads

Francisco Javier Godino jgodino at yahoo.com
Sat Sep 6 17:26:01 UTC 2014


Hello:

I have a issue with a Service. 
I developed thisService. 
It's an extension of Service:


public class MostrarImagenesService extends Service{
...

@Override

    protected Task createTask() {
        return new Task() {

            @Override
            protected Object call() throws Exception {

......

                return null;
                
            }
}



This is the way that I invoque the service:


switch (MostrarImagenesService.getInstance().getState()) {

case READY:
MostrarImagenesService.getInstance().start();
   

break;

case SUCCEEDED:

                                    
MostrarImagenesService.getInstance().restart();
                                            
                break;

        default:

                log.info("GrabadoraDeImagenesService State: Grabadora en Funcionamiento");

}



I see this in the log:

[Thread-10] INFO  servicios.MostrarImagenesService  - MostrarImagenesService: call INICIO trama:00552

the second time that i invoque the service:

[Thread-14] INFO  servicios.MostrarImagenesService  - MostrarImagenesService: call INICIO trama:00553

It is running over a new Thread (Thread 14).



How I can avoid creating new thread?
This service will be constantly invoked.
Can this affect the VM?

Thanks


More information about the openjfx-dev mailing list