Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX Application doesn't terminate after using Platform.exit()

I am using JavaFX 2.2 and i have a class which extends Application Class. Here is my code. After that my program finished it's work, it doesn't terminate and continue it's life. What shod I do?

new JFXPanel();
Platform.runLater(new Runnable() {
        @Override
        public void run() {
            ApplicationExtendedClass s = new ApplicationExtendedClass();
            s.start(new Stage());
        }
    });
    synchronized (SynchronyzingObject.getInstance()) {
        try {
            SynchronyzingObject.getInstance().wait();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    Platform.exit();

I use SynchronyzingObject to synchronize work between my threads and wait the work of another thread end and then Platform.exit() works to exit that. Also I wrote Platform.exit() in the end of work of that thread, before notifying the SynchronyzingObject. What should I do in order to my program get finished.

EDIT :

This application runs in the middle of another program in order to do some data and adding them to database, and after finish of this program i don't want my whole project get closed, I just want thread of this application got terminate.

like image 924
Seyed Mohammad Chavoshian Avatar asked Dec 10 '13 08:12

Seyed Mohammad Chavoshian


1 Answers

Use System.exit(0); with your code for closing the application.

Platform.exit();
System.exit(0);
like image 162
Shreyas Dave Avatar answered Nov 02 '22 21:11

Shreyas Dave