5

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.

1 Answer 1

11

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

Platform.exit();
System.exit(0);
Sign up to request clarification or add additional context in comments.

4 Comments

System.exit(0) kill all java processes, isn't it?
I don't want this, i want other threads continue their lifes.
You said you application doesn't terminate that is why above was your solution. Provide detail of your problem.
Sorry you are right, now I will edit my post to with more detail.

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.