JavaFX应用程序在CentOS上死锁

时间:2017-01-05 09:36:46

标签: java javafx centos

我的JavaFX应用程序在Windows和Ubuntu下运行良好。 但是,在CentOS下,它一旦失去焦点就不会响应(例如,当我切换到另一个应用程序然后返回时)。一旦我用鼠标移动窗口,它也会冻结。

这种情况甚至发生在这个最小的JavaFX应用程序中:

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

public class SampleFX extends Application{
@Override
public void start(Stage primaryStage) throws Exception {
    Button btn = new Button("Click");
    btn.setOnAction(e -> btn_click());
    StackPane frame = new StackPane();
    frame.getChildren().add(btn);

    Scene scene = new Scene(frame, 200, 50);

    primaryStage.setScene(scene);
    primaryStage.setTitle("Hello World");
    primaryStage.show();
}
private void btn_click() {
    System.out.println("button was clicked");
}

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

}

Visual VM为我提供了以下threaddump:

2017-01-05 09:08:20
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode):
"Attach Listener" #14 daemon prio=9 os_prio=0 tid=0x00007fdd4c001000 nid=0x6187 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   Locked ownable synchronizers:
    - None
"Prism Font Disposer" #13 daemon prio=10 os_prio=0 tid=0x00007fdd2c1b1000 nid=0x617b in Object.wait() [0x00007fdd517a5000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000073f0d3158> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    - locked <0x000000073f0d3158> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
    at com.sun.javafx.font.Disposer.run(Disposer.java:93)
    at java.lang.Thread.run(Thread.java:745)
   Locked ownable synchronizers:
    - None
"JavaFX-Launcher" #12 prio=5 os_prio=0 tid=0x00007fdd8c234800 nid=0x6179 waiting on condition [0x00007fdd68225000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000073e5ca518> (a java.util.concurrent.CountDownLatch$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:873)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at com.sun.javafx.application.LauncherImpl$$Lambda$56/683287027.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
   Locked ownable synchronizers:
    - None
"JavaFX Application Thread" #11 prio=5 os_prio=0 tid=0x00007fdd8c231000 nid=0x6178 runnable [0x00007fdd68326000]
   java.lang.Thread.State: RUNNABLE
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$42/1535128843.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
   Locked ownable synchronizers:
    - None
"Thread-1" #10 daemon prio=5 os_prio=0 tid=0x00007fdd8c22a800 nid=0x6177 waiting on condition [0x00007fdd68427000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000073dfe2dc8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:492)
    at com.sun.glass.ui.InvokeLaterDispatcher.run(InvokeLaterDispatcher.java:108)
   Locked ownable synchronizers:
    - None
"QuantumRenderer-0" #8 daemon prio=5 os_prio=0 tid=0x00007fdd8c165800 nid=0x6176 waiting on condition [0x00007fdd6ae15000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000073dd58dd8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.lang.Thread.run(Thread.java:745)
   Locked ownable synchronizers:
    - None
"Service Thread" #7 daemon prio=9 os_prio=0 tid=0x00007fdd8c0b8800 nid=0x6174 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   Locked ownable synchronizers:
    - None
"C1 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007fdd8c0b5800 nid=0x6173 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   Locked ownable synchronizers:
    - None
"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007fdd8c0b2800 nid=0x6172 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   Locked ownable synchronizers:
    - None
"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007fdd8c0b1000 nid=0x6171 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   Locked ownable synchronizers:
    - None
"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007fdd8c07e800 nid=0x6170 in Object.wait() [0x00007fdd6b4b1000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000073d808e98> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    - locked <0x000000073d808e98> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
   Locked ownable synchronizers:
    - None
"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007fdd8c07a000 nid=0x616f in Object.wait() [0x00007fdd6b5b2000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000073d806b40> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
    - locked <0x000000073d806b40> (a java.lang.ref.Reference$Lock)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
   Locked ownable synchronizers:
    - None
"main" #1 prio=5 os_prio=0 tid=0x00007fdd8c008800 nid=0x6167 waiting on condition [0x00007fdd92f7f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000073e02a6c0> (a java.util.concurrent.CountDownLatch$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:200)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:143)
    at javafx.application.Application.launch(Application.java:252)
    at SampleFX.main(SampleFX.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
   Locked ownable synchronizers:
    - None
"VM Thread" os_prio=0 tid=0x00007fdd8c072000 nid=0x616d runnable
"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007fdd8c01d800 nid=0x616b runnable
"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007fdd8c01f800 nid=0x616c runnable
"VM Periodic Task Thread" os_prio=0 tid=0x00007fdd8c0bb000 nid=0x6175 waiting on condition
JNI global references: 545

似乎主要线程被锁定了...但是这样一个最小的应用程序中锁定的原因是什么?

0 个答案:

没有答案