SOLVED: Companion object initialization deadlock with synchronization. Why

Can anyone explain to me why the following blocks.
I have (snippet not compiled):

object HeadlessWebKit extends Application {

  def launchBackground(args: Array[String]): Unit = {
    this.synchronized {
    }
  }
}

I then set-up initialization so:

object PlotlyModifier {
  def initWebKit():Unit = {
    HeadlessWebKit.launchBackground(Array[String]())
  }
}

class PlotlyModifier extends PostModifier {
  override val name: String = "plotly"
  PlotlyModifier.initWebKit()
}

Now class PlotlyModifier is instantiated via Java reflection.
If I execute this then class initialization deadlocks.
But if I remove launchBackground's this.synchronized,
then execution proceeds as expected.

I am assuming HeadlessWebKitis deadlocking on itself. Why?

TIA.

Would need to see more of your code to understand this.

If one thread would hold a lock on HeadlessWebKit and a second thread would call HeadlessWebKit.launchBackground (for example, by creating an instance of PlotlyModifier), then the second thread would have to wait until the first thread releases the lock. On the other hand, I don’t see how that can happen unless there is another place with synchronization over HeadlessWebKit.

As for me, the first step after suspecting a deadlock is promptly making a thread dump and then analyzing it.

@curoli Their are only two threads I have control over. The main application and the thread I create to launch the JavaFX application in the background. I have tested and used this successfully in uTetss and standard applications. No problem. However recreating this is difficult because I am executing this as a Mill module that invokes an MDoc PostModifier. The PostModfier is instantiated via reflection. My attempt to recreate this can be found here. I suspect its the Java reflectiob that is the culprit.

@tarsa Yep. I can do that. I used jvisualvm and placed the dump below (did not see an option to attach the file). My code is related to "Thread-1" #19. Other JavaFX related threads seems to be waiting on a latch ("JavaFX Application Thread" #17). I use no latches.

What seems to be happening is that in #19 I start the launch. Here I lock on HeadlessWebKit. Then #17 executes and here I suspect it tries to lock on the same lock. Question is why is #17 starting up? Ofcourse I can be totally off the mark but elapsed time seems to indicate this sequence.

Any suggestions are welcome. Relevant source can be found here and here.

TIA

2019-12-07 09:07:29
Full thread dump OpenJDK 64-Bit Server VM (11.0.4+11-post-Ubuntu-1ubuntu218.04.3 mixed mode, sharing):

Threads class SMR info:
_java_thread_list=0x00007f81e4000b20, length=24, elements={
0x00007f8358237800, 0x00007f8358239800, 0x00007f8358240000, 0x00007f8358242000,
0x00007f8358244000, 0x00007f8358246800, 0x00007f83582a9000, 0x00007f835826d800,
0x00007f835a410800, 0x00007f835a412800, 0x00007f835a4ab000, 0x00007f835a4c3800,
0x00007f835a4c5000, 0x00007f8298013000, 0x00007f829c005800, 0x00007f8298102000,
0x00007f82981b9800, 0x00007f8358019800, 0x00007f8300001000, 0x00007f82ec2f0000,
0x00007f82c4005000, 0x00007f81e8023000, 0x00007f81e8047800, 0x00007f82c4006000
}

"Reference Handler" #2 daemon prio=10 os_prio=0 cpu=4,70ms elapsed=115,89s tid=0x00007f8358237800 nid=0x1ded waiting on condition  [0x00007f834026f000]
   java.lang.Thread.State: RUNNABLE
        at java.lang.ref.Reference.waitForReferencePendingList([email protected]/Native Method)
        at java.lang.ref.Reference.processPendingReferences([email protected]/Reference.java:241)
        at java.lang.ref.Reference$ReferenceHandler.run([email protected]/Reference.java:213)

   Locked ownable synchronizers:
        - None

"Finalizer" #3 daemon prio=8 os_prio=0 cpu=0,26ms elapsed=115,88s tid=0x00007f8358239800 nid=0x1dee in Object.wait()  [0x00007f834016e000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <0x000000060d472f00> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x000000060d472f00> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:176)
        at java.lang.ref.Finalizer$FinalizerThread.run([email protected]/Finalizer.java:170)

   Locked ownable synchronizers:
        - None

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 cpu=0,28ms elapsed=115,88s tid=0x00007f8358240000 nid=0x1def runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 cpu=12427,06ms elapsed=115,88s tid=0x00007f8358242000 nid=0x1df0 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   No compile task

   Locked ownable synchronizers:
        - None

"C1 CompilerThread0" #8 daemon prio=9 os_prio=0 cpu=8601,80ms elapsed=115,88s tid=0x00007f8358244000 nid=0x1df1 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   No compile task

   Locked ownable synchronizers:
        - None

"Sweeper thread" #9 daemon prio=9 os_prio=0 cpu=281,39ms elapsed=115,88s tid=0x00007f8358246800 nid=0x1df2 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"Service Thread" #10 daemon prio=9 os_prio=0 cpu=0,14ms elapsed=115,85s tid=0x00007f83582a9000 nid=0x1df3 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"Common-Cleaner" #11 daemon prio=8 os_prio=0 cpu=5,76ms elapsed=115,84s tid=0x00007f835826d800 nid=0x1df5 in Object.wait()  [0x00007f8321efc000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <no object reference available>
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x000000060d4730c0> (a java.lang.ref.ReferenceQueue$Lock)
        at jdk.internal.ref.CleanerImpl.run([email protected]/CleanerImpl.java:148)
        at java.lang.Thread.run([email protected]/Thread.java:834)
        at jdk.internal.misc.InnocuousThread.run([email protected]/InnocuousThread.java:134)

   Locked ownable synchronizers:
        - None

"Java2D Disposer" #13 daemon prio=10 os_prio=0 cpu=0,46ms elapsed=115,02s tid=0x00007f835a410800 nid=0x1e04 in Object.wait()  [0x00007f82b6ffc000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <0x000000060d9a6578> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x000000060d9a6578> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:176)
        at sun.java2d.Disposer.run([email protected]/Disposer.java:144)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"AWT-XAWT" #14 daemon prio=6 os_prio=0 cpu=25,01ms elapsed=115,02s tid=0x00007f835a412800 nid=0x1e05 runnable  [0x00007f82b6efb000]
   java.lang.Thread.State: RUNNABLE
        at sun.awt.X11.XToolkit.waitForEvents([email protected]/Native Method)
        at sun.awt.X11.XToolkit.run([email protected]/XToolkit.java:688)
        at sun.awt.X11.XToolkit.run([email protected]/XToolkit.java:652)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"QuantumRenderer-0" #15 daemon prio=5 os_prio=0 cpu=75,59ms elapsed=114,94s tid=0x00007f835a4ab000 nid=0x1e06 waiting on condition  [0x00007f82b6dfa000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
        - parking to wait for  <0x000000061038f178> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park([email protected]/LockSupport.java:194)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await([email protected]/AbstractQueuedSynchronizer.java:2081)
        at java.util.concurrent.LinkedBlockingQueue.take([email protected]/LinkedBlockingQueue.java:433)
        at java.util.concurrent.ThreadPoolExecutor.getTask([email protected]/ThreadPoolExecutor.java:1054)
        at java.util.concurrent.ThreadPoolExecutor.runWorker([email protected]/ThreadPoolExecutor.java:1114)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run([email protected]/ThreadPoolExecutor.java:628)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"JavaFX Application Thread" #17 prio=5 os_prio=0 cpu=1619,85ms elapsed=114,89s tid=0x00007f835a4c3800 nid=0x1e07 in Object.wait()  [0x00007f82b68e9000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <no object reference available>
        at java.lang.Object.wait([email protected]/Object.java:328)
        at com.sun.glass.ui.monocle.RunnableQueue.getNextRunnable(RunnableQueue.java:58)
        - waiting to re-lock in wait() <0x000000060e0782a8> (a com.sun.glass.ui.monocle.RunnableQueue)
        at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
        at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"Thread-1" #19 prio=5 os_prio=0 cpu=4,37ms elapsed=114,87s tid=0x00007f835a4c5000 nid=0x1e08 waiting on condition  [0x00007f82b6714000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
        - parking to wait for  <0x0000000610600180> (a java.util.concurrent.CountDownLatch$Sync)
        at java.util.concurrent.locks.LockSupport.park([email protected]/LockSupport.java:194)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt([email protected]/AbstractQueuedSynchronizer.java:885)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly([email protected]/AbstractQueuedSynchronizer.java:1039)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly([email protected]/AbstractQueuedSynchronizer.java:1345)
        at java.util.concurrent.CountDownLatch.await([email protected]/CountDownLatch.java:232)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:213)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:156)
        at javafx.application.Application.launch(Application.java:227)
        at utils.HeadlessWebKit$$anon$2.run(HeadlessWebKit.scala:493)

   Locked ownable synchronizers:
        - None

"Timer-0" #20 daemon prio=5 os_prio=0 cpu=457,74ms elapsed=114,86s tid=0x00007f8298013000 nid=0x1e09 in Object.wait()  [0x00007f82b6613000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <no object reference available>
        at java.util.TimerThread.mainLoop([email protected]/Timer.java:553)
        - waiting to re-lock in wait() <0x000000061070c380> (a java.util.TaskQueue)
        at java.util.TimerThread.run([email protected]/Timer.java:506)

   Locked ownable synchronizers:
        - None

"JavaFX-Launcher" #21 prio=5 os_prio=0 cpu=2,41ms elapsed=114,86s tid=0x00007f829c005800 nid=0x1e0a waiting on condition  [0x00007f82b6512000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
        - parking to wait for  <0x00000006106b2c00> (a java.util.concurrent.CountDownLatch$Sync)
        at java.util.concurrent.locks.LockSupport.park([email protected]/LockSupport.java:194)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt([email protected]/AbstractQueuedSynchronizer.java:885)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly([email protected]/AbstractQueuedSynchronizer.java:1039)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly([email protected]/AbstractQueuedSynchronizer.java:1345)
        at java.util.concurrent.CountDownLatch.await([email protected]/CountDownLatch.java:232)
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:856)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at com.sun.javafx.application.LauncherImpl$$Lambda$156/0x00000008401d5440.run(Unknown Source)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"Prism Font Disposer" #23 daemon prio=10 os_prio=0 cpu=0,26ms elapsed=114,52s tid=0x00007f8298102000 nid=0x1e0c in Object.wait()  [0x00007f82b42f4000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <0x0000000610659778> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x0000000610659778> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:176)
        at com.sun.javafx.font.Disposer.run(Disposer.java:93)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"Disposer" #24 daemon prio=10 os_prio=0 cpu=1,88ms elapsed=114,50s tid=0x00007f82981b9800 nid=0x1e0e in Object.wait()  [0x00007f82b41f3000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <no object reference available>
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x00000006103e8908> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove([email protected]/ReferenceQueue.java:176)
        at com.sun.webkit.Disposer.run(Disposer.java:122)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"DestroyJavaVM" #25 prio=5 os_prio=0 cpu=12626,70ms elapsed=102,86s tid=0x00007f8358019800 nid=0x1de4 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"Attach Listener" #26 daemon prio=9 os_prio=0 cpu=89,78ms elapsed=97,05s tid=0x00007f8300001000 nid=0x1edb waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"RMI TCP Accept-0" #27 daemon prio=9 os_prio=0 cpu=1,26ms elapsed=96,72s tid=0x00007f82ec2f0000 nid=0x1edd runnable  [0x00007f8320dc0000]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept([email protected]/Native Method)
        at java.net.AbstractPlainSocketImpl.accept([email protected]/AbstractPlainSocketImpl.java:458)
        at java.net.ServerSocket.implAccept([email protected]/ServerSocket.java:551)
        at java.net.ServerSocket.accept([email protected]/ServerSocket.java:519)
        at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept([email protected]/LocalRMIServerSocketFactory.java:52)
        at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop([email protected]/TCPTransport.java:394)
        at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run([email protected]/TCPTransport.java:366)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"RMI TCP Connection(1)-127.0.0.1" #28 daemon prio=9 os_prio=0 cpu=348,63ms elapsed=96,70s tid=0x00007f82c4005000 nid=0x1ee1 runnable  [0x00007f81fb3ee000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0([email protected]/Native Method)
        at java.net.SocketInputStream.socketRead([email protected]/SocketInputStream.java:115)
        at java.net.SocketInputStream.read([email protected]/SocketInputStream.java:168)
        at java.net.SocketInputStream.read([email protected]/SocketInputStream.java:140)
        at java.io.BufferedInputStream.fill([email protected]/BufferedInputStream.java:252)
        at java.io.BufferedInputStream.read([email protected]/BufferedInputStream.java:271)
        - locked <0x0000000640c6d458> (a java.io.BufferedInputStream)
        at java.io.FilterInputStream.read([email protected]/FilterInputStream.java:83)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages([email protected]/TCPTransport.java:544)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0([email protected]/TCPTransport.java:796)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0([email protected]/TCPTransport.java:677)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$2017/0x0000000840bb0040.run([email protected]/Unknown Source)
        at java.security.AccessController.doPrivileged([email protected]/Native Method)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run([email protected]/TCPTransport.java:676)
        at java.util.concurrent.ThreadPoolExecutor.runWorker([email protected]/ThreadPoolExecutor.java:1128)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run([email protected]/ThreadPoolExecutor.java:628)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - <0x0000000640f00800> (a java.util.concurrent.ThreadPoolExecutor$Worker)

"RMI Scheduler(0)" #29 daemon prio=9 os_prio=0 cpu=0,58ms elapsed=96,68s tid=0x00007f81e8023000 nid=0x1ee2 waiting on condition  [0x00007f81fb2ef000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
        - parking to wait for  <0x000000064115a3d8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos([email protected]/LockSupport.java:234)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos([email protected]/AbstractQueuedSynchronizer.java:2123)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take([email protected]/ScheduledThreadPoolExecutor.java:1182)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take([email protected]/ScheduledThreadPoolExecutor.java:899)
        at java.util.concurrent.ThreadPoolExecutor.getTask([email protected]/ThreadPoolExecutor.java:1054)
        at java.util.concurrent.ThreadPoolExecutor.runWorker([email protected]/ThreadPoolExecutor.java:1114)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run([email protected]/ThreadPoolExecutor.java:628)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"JMX server connection timeout 30" #30 daemon prio=9 os_prio=0 cpu=50,09ms elapsed=96,67s tid=0x00007f81e8047800 nid=0x1ee4 in Object.wait()  [0x00007f81fb1ee000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait([email protected]/Native Method)
        - waiting on <no object reference available>
        at com.sun.jmx.remote.internal.ServerCommunicatorAdmin$Timeout.run([email protected]/ServerCommunicatorAdmin.java:171)
        - waiting to re-lock in wait() <0x0000000640cc4138> (a [I)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - None

"RMI TCP Connection(2)-127.0.0.1" #31 daemon prio=9 os_prio=0 cpu=371,89ms elapsed=95,58s tid=0x00007f82c4006000 nid=0x1eea runnable  [0x00007f82301ed000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0([email protected]/Native Method)
        at java.net.SocketInputStream.socketRead([email protected]/SocketInputStream.java:115)
        at java.net.SocketInputStream.read([email protected]/SocketInputStream.java:168)
        at java.net.SocketInputStream.read([email protected]/SocketInputStream.java:140)
        at java.io.BufferedInputStream.fill([email protected]/BufferedInputStream.java:252)
        at java.io.BufferedInputStream.read([email protected]/BufferedInputStream.java:271)
        - locked <0x0000000640800148> (a java.io.BufferedInputStream)
        at java.io.FilterInputStream.read([email protected]/FilterInputStream.java:83)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages([email protected]/TCPTransport.java:544)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0([email protected]/TCPTransport.java:796)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0([email protected]/TCPTransport.java:677)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$2017/0x0000000840bb0040.run([email protected]/Unknown Source)
        at java.security.AccessController.doPrivileged([email protected]/Native Method)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run([email protected]/TCPTransport.java:676)
        at java.util.concurrent.ThreadPoolExecutor.runWorker([email protected]/ThreadPoolExecutor.java:1128)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run([email protected]/ThreadPoolExecutor.java:628)
        at java.lang.Thread.run([email protected]/Thread.java:834)

   Locked ownable synchronizers:
        - <0x0000000640f00d40> (a java.util.concurrent.ThreadPoolExecutor$Worker)

"VM Thread" os_prio=0 cpu=188,38ms elapsed=115,89s tid=0x00007f8358234800 nid=0x1dec runnable  

"GC Thread#0" os_prio=0 cpu=86,29ms elapsed=115,89s tid=0x00007f8358030800 nid=0x1de7 runnable  

"GC Thread#1" os_prio=0 cpu=86,05ms elapsed=115,47s tid=0x00007f8314001000 nid=0x1df7 runnable  

"GC Thread#2" os_prio=0 cpu=88,06ms elapsed=115,47s tid=0x00007f8314002800 nid=0x1df8 runnable  

"GC Thread#3" os_prio=0 cpu=84,24ms elapsed=115,47s tid=0x00007f8314004000 nid=0x1df9 runnable  

"GC Thread#4" os_prio=0 cpu=71,56ms elapsed=115,47s tid=0x00007f8314005800 nid=0x1dfa runnable  

"GC Thread#5" os_prio=0 cpu=80,28ms elapsed=115,47s tid=0x00007f8314007000 nid=0x1dfb runnable  

"GC Thread#6" os_prio=0 cpu=216,30ms elapsed=115,47s tid=0x00007f8314008800 nid=0x1dfc runnable  

"GC Thread#7" os_prio=0 cpu=88,02ms elapsed=115,47s tid=0x00007f831400a000 nid=0x1dfd runnable  

"GC Thread#8" os_prio=0 cpu=86,44ms elapsed=115,47s tid=0x00007f831400c000 nid=0x1dfe runnable  

"GC Thread#9" os_prio=0 cpu=87,87ms elapsed=115,47s tid=0x00007f831400d800 nid=0x1dff runnable  

"G1 Main Marker" os_prio=0 cpu=3,13ms elapsed=115,89s tid=0x00007f835806a800 nid=0x1de8 runnable  

"G1 Conc#0" os_prio=0 cpu=192,36ms elapsed=115,89s tid=0x00007f835806c800 nid=0x1de9 runnable  

"G1 Conc#1" os_prio=0 cpu=184,81ms elapsed=114,44s tid=0x00007f8324001000 nid=0x1e0f runnable  

"G1 Conc#2" os_prio=0 cpu=184,63ms elapsed=114,44s tid=0x00007f8324002800 nid=0x1e10 runnable  

"G1 Refine#0" os_prio=0 cpu=13,43ms elapsed=115,89s tid=0x00007f83581f6000 nid=0x1dea runnable  

"G1 Refine#1" os_prio=0 cpu=8,01ms elapsed=109,67s tid=0x00007f8318001000 nid=0x1e1a runnable  

"G1 Refine#2" os_prio=0 cpu=7,30ms elapsed=109,67s tid=0x00007f8210001000 nid=0x1e1b runnable  

"G1 Refine#3" os_prio=0 cpu=6,40ms elapsed=109,67s tid=0x00007f8204001000 nid=0x1e1c runnable  

"G1 Refine#4" os_prio=0 cpu=4,84ms elapsed=109,67s tid=0x00007f8208001000 nid=0x1e1d runnable  

"G1 Refine#5" os_prio=0 cpu=0,69ms elapsed=109,67s tid=0x00007f81fc001000 nid=0x1e1e runnable  

"G1 Refine#6" os_prio=0 cpu=0,08ms elapsed=109,67s tid=0x00007f8200001000 nid=0x1e1f runnable  

"G1 Young RemSet Sampling" os_prio=0 cpu=38,31ms elapsed=115,89s tid=0x00007f83581f8000 nid=0x1deb runnable  
"VM Periodic Task Thread" os_prio=0 cpu=76,49ms elapsed=115,85s tid=0x00007f83582ab800 nid=0x1df4 waiting on condition  

JNI global refs: 105, weak refs: 0


It’s weird that you have extended javafx.application.Application twice - in a class and in an object.

Judging by ScalaFX solution here https://github.com/scalafx/scalafx/blob/master/scalafx/src/main/scala/scalafx/application/JFXApp.scala and here https://github.com/scalafx/scalafx/blob/master/scalafx/src/main/scala/scalafx/application/AppHelper.scala it seems that only the class should extend javafx.application.Application and not the main object.

True. I was having an issue that I reported in this forum here. Going to check this again. Thanks.

Finally figured out the problem. It is not an issue with deadlock, initialization ordering, extending the javaFX Application or even dynamic class loading. I am executing a dynamicaly loaded object that executes in a JVM fork in Mill via os-Lib. In this object I launch a javaFX Application which creates a daemon thread. As a result the JVM fork does not terminate.

Because JVM forks redirect and collect standard output, one can only print this out after the JVM has terminated. So all the printlns I used did not show up. Hence my concluding that their was a deadlock.

Thanks and apologies for those who looked into this.