Why do we still get SWT Invalid thread access Exception on Mac with -XstartOnFirstThread VM option?

我是研究僧i 提交于 2019-12-24 03:16:53

问题


I'm working on a context simulator named siafu, just the first step, try to build and run it on Mac OSX 10.6.8, but I'm confused that it fails to run with Exception:

***WARNING: Display must be created on main thread due to Cocoa restrictions.
Exception in thread "GUI thread" org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.widgets.Display.error(Unknown Source)
    at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
    at org.eclipse.swt.widgets.Display.create(Unknown Source)
    at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
    at de.nec.nle.siafu.graphics.GUI.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:680)

The script to run is like this, can anyone kindly point out why do we have exception even though we have specify the -XstartOnFirstThread?

#!/bin/sh

if [ "$1" = "-h" ]; then echo "Syntax: $0 [SimulationJarFile]"; exit 1; fi
if [ -n "$1" ]; then SIMULATION="--simulation=$1"; fi

java -Xmx512m -XstartOnFirstThread -classpath \
lib/org.eclipse.swt.osx64.jar:\
Siafu.jar:\
lib/org.apache.commons.collections-3.2.1.jar:\
lib/org.apache.commons.configuration-1.6.0.jar:\
lib/org.apache.commons.lang-2.4.0.jar:\
lib/org.apache.commons.logging-1.1.1.jar \
de.nec.nle.siafu.control.Siafu $SIMULATION

来源:https://stackoverflow.com/questions/7395994/why-do-we-still-get-swt-invalid-thread-access-exception-on-mac-with-xstartonfir

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!