据说 `libX11` 不是线程安全的。这是否意味着我不能将 Java AWT 与其他也使用 X11 的东西(如 Qt)混合使用?

It's said that `libX11` is not thread-safe. Does this mean I can't mix Java AWT with something else that also uses X11, like Qt?

据说 libX11 不是线程安全的。这是否意味着如果我有一个已经使用 AWT(直接或通过 Swing 间接使用)的 Java 应用程序,我就不能使用除此之外的其他工具包(如 Qt 或其他使用 X11 的库) (在同一个进程中)?

据我了解,这些工具包不会相互了解,会在 libX11 之上启动它们自己的事件处理线程,因此在多个线程中使用 libX11,这听起来有问题,因为libX11 不是线程安全的。

或者 AWT 是否有一些我不知道的方法可以在同一进程中与 libX11 的其他用户同步?

如果您有单独的顶层 windows,混合工具包应该很容易。您也可以将它们混合在同一个 window 中,但这很棘手(您需要合并事件循环)并且很难看。

Qt Jambi implements its own event system based on Qt/C++. This event loop is separate from the one in other toolkits such as AWT/Swing or in SWT. As a concequence, it is not possible to have Jambi widgets and widgets from other toolkits in the same part of the user interface. Having a toplevel window running Jambi and another toplevel window running AWT/Swing does not run into this limitation.

Although it is possible to merge event loops for different toolkits, so that a QPushButton can inhabit a JSplitPane, it often not desired as this means that different parts of the same user inteface may have slightly different look&feel. Different repaint behaviour, fonts etc.

source