Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248381

Create a daemon thread for MonocleTimer

XMLWordPrintable

        ADDITIONAL SYSTEM INFORMATION :
        $ uname -a
        Linux touchc 2.6.35.3-850-gbc67621+ #619 PREEMPT
            Thu Dec 22 15:29:00 CST 2016 armv7l armv7l armv7l GNU/Linux

        $ ldd --version
        ldd (Ubuntu EGLIBC 2.19-0ubuntu6.15) 2.19

        $ getconf GNU_LIBPTHREAD_VERSION
        NPTL 2.19

        $ ~/opt/jdk-14.0.1+7/bin/java -version
        openjdk version "14.0.1" 2020-04-14
        OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
        OpenJDK Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)

        Additional:
        Affects Version/s: openjfx15 (the JDK was version 14.0.1)
        CPU: arm (32-bit ARMv7 "armhf")

        I believe the bug is a regression error, if there's a place to add that, too. (It did not occur in JavaFX 14.)

        A DESCRIPTION OF THE PROBLEM :
        JavaFX applications on the Monocle platform do not terminate after a call to Platform.exit. Instead, they hang because the pulse timer created by MonocleTimer is a non-daemon thread.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the JavaFX application included below on a Monocle platform.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The program should terminate after printing three non-daemon threads, as shown below:

        ubuntu@touchc:~/src/exitfx$ sudo $HOME/opt/jdk-14.0.1+7/bin/java \
            --add-modules=javafx.controls --module-path=$HOME/lib/armv6hf-sdk/lib \
            -Dglass.platform=Monocle -Dmonocle.platform=EPD -Dprism.order=sw \
            -Dmonocle.input.18/0/0/0.maxX=800 -Dmonocle.input.18/0/0/0.maxY=600 \
            -jar dist/exitfx.jar
        Thread[JavaFX Application Thread,5,Event]
        Thread[JavaFX-Launcher,5,main]
        Thread[main,5,main]
        ubuntu@touchc:~/src/exitfx$

        ACTUAL -
        The program hangs after printing four non-daemon threads, as shown below:

        ubuntu@touchc:~/src/exitfx$ sudo $HOME/opt/jdk-14.0.1+7/bin/java \
            --add-modules=javafx.controls --module-path=$HOME/lib/armv6hf-sdk/lib \
            -Dglass.platform=Monocle -Dmonocle.platform=EPD -Dprism.order=sw \
            -Dmonocle.input.18/0/0/0.maxX=800 -Dmonocle.input.18/0/0/0.maxY=600 \
            -jar dist/exitfx.jar
        Thread[JavaFX Application Thread,5,Event]
        Thread[pool-2-thread-1,5,Event]
        Thread[JavaFX-Launcher,5,main]
        Thread[main,5,main]


        ---------- BEGIN SOURCE ----------
        package org.status6.exitfx;

        import javafx.application.Application;
        import static javafx.application.Application.launch;
        import javafx.application.Platform;
        import javafx.scene.Scene;
        import javafx.scene.control.Button;
        import javafx.scene.layout.StackPane;
        import javafx.stage.Stage;

        public class ExitFX extends Application {

            @Override
            public void start(Stage stage) {
                Button button = new Button("Exit");
                button.setOnAction(e -> Platform.exit());
                StackPane root = new StackPane(button);

                Scene scene = new Scene(root, 800, 600);
                stage.setTitle("Exit App");
                stage.setScene(scene);
                stage.show();
            }

            @Override
            public void stop() {
                Thread.getAllStackTraces().keySet().forEach(thread -> {
                    if (!thread.isDaemon()) {
                        System.out.println(thread);
                    }
                });
            }

            public static void main(String[] args) {
                launch(args);
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        The source-code workaround is to call System.exit in the stop method of the JavaFX application. The command-line workaround is to press Ctrl-C to cancel the program when it hangs.


        FREQUENCY : always


          1. ExitFX.java
            0.9 kB
            Pardeep Sharma

              jgneff John Neffenger
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: