当前位置:  开发笔记 > 编程语言 > 正文

如何选择AWT-EventQueue线程,当有多个线程时

如何解决《如何选择AWT-EventQueue线程,当有多个线程时》经验,为你挑选了0个好方法。

我使用DLL注入和一些jni技巧成功地在运行的Oracle Forms应用程序中注入了我自己的Java代码.(Windows 7,32位,Oracle Forms 11,JRE Java 8)

我能够遍历组件树,并在一些基本的Java对象(例如来自类的对象)中查询和设置值 oracle.forms.ui.VTextField

当我试图模拟用户点击时,我陷入了困境 oracle.apps.fnd.ui.Button

我尝试了两件事:

    调用类的simulatePush方法AbstractButton

    调用类的activate方法PushButton

(这两个类在类层次结构中Button)

结果相同:1.首先,它工作正常:当按钮是"搜索"按钮时,搜索完成并显示结果.然后,它立刻打破了应用程序,弹出一个说法FRM-92100 Your connection to the Server was interrupted.

从那里,应用程序挂起.

更新: 似乎导致与服务器断开连接的错误是:

java.lang.SecurityException:此KeyboardFocusManager未安装在当前线程的上下文中java.awt.KeyboardFocusManager.checkCurrentKFMSecurity(未知源)位于java.awt.KeyboardFocusManager.processSynchronousLightweightTransfer上的java.awt.KeyboardFocusManager.getGlobalFocusOwner(未知源)中(未知来源)来自)java.awt.Component.requestFocusHelper的java.awt.Component.requestFocusHelper(未知来源)的sun.awt.windows.WComponentPeer.processSynchronousLightweightTransfer(本地方法)at sun.awt.windows.WComponentPeer.requestFocus(未知来源) oracle.forms.hand处理器上oracle.forms.handler.UICommon.updateFocus(未知来源)位于oracle.forms.hand处理器上的java.awt.Component.requestFocus(未知源)处的(未知源)位于oracle.forms.hand.handler.Ja上的oracle.forms.hand.hand上的oracle.forms.hand.hand上的oracle.forms.hand.hand.Ter上的oracle.forms.hand.hand.Th上的oracle.forms.handler.Ja上的未知来源(未知来源).UICommon.setFVP(未知来源)rce)at oracle.forms.engine.Uuomom.onUpdate(Unknown Source)at oracle.forms.engine.Runform.onUpdateHandler(Unknown Source)at oracle.forms.engine.Runform.processMessage(Unknown Source)at oracle.forms.engine oracle.forms.engine.Runform.onMessage(未知来源)位于oracle.forms.engine.Runform.processEventEnd(未知来源)的oracle.forms.engine.Runform.onMessage(未知来源)的.runform.processSet(未知来源) at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)at oracle.ewt.button.PushButton.activate(Unknown Source)at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native方法)at sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源),位于CustomAWT.run上的java.lang.reflect.Method.invoke(未知来源)(CustomAWT.java) :34)在java.awt.EventQueue.dispatchEventImpl(未知Sou)的java.awt.event.InvocationEvent.dispatch(未知来源)rce)java.awt.EventQueue.access $ 400(未知来源)java.awt.EventQueue $ 2.run(未知来源)java.awt.EventQueue $ 2.run(未知来源)java.security.AccessController.doPrivileged(原始方法)java.security.AccessControlContext $ 1.doIntersectionPrivilege(未知来源)java.awt.EventDispatchEvent(未知来源)java.awt.EventDispatchThread.pumpOneEventForFilters(未知来源)java.awt.EventDispatchThread.pumpEventsForFilter(未知) java.awt.EventDispatchThread.run上的java.awt.EventDispatchThread.pumpEvents(未知来源)java.awt.EventDispatchThread.run(未知来源)java.awt.EventDispatchThread.pumpEventsForHierarchy(未知来源)

我的代码在这里:CustomAWT.run(CustomAWT.java:34)并且被调用invokeLater.问题可能是:在调用oracle.ewt.button.PushButton.activate方法时,我不在正确的EDT中.

使用Java控制台中的"列出线程",我得到了:

Dump thread list ...
Group main,ac=30,agc=2,pri=10
    main,5,alive
    traceMsgQueueThread,5,alive,daemon
    Timer-0,5,alive
    Java Plug-In Pipe Worker Thread (Client-Side),5,alive,daemon
    AWT-Shutdown,5,alive
    AWT-Windows,6,alive,daemon
    AWT-EventQueue-0,6,alive
    SysExecutionTheadCreator,5,alive,daemon
    CacheMemoryCleanUpThread,5,alive,daemon
    CacheCleanUpThread,5,alive,daemon
    Browser Side Object Cleanup Thread,5,alive
    JVM[id=0]-Heartbeat,5,alive,daemon
    Windows Tray Icon Thread,5,alive
    Thread-13,5,alive
Group Plugin Thread Group,ac=3,agc=0,pri=10
    AWT-EventQueue-1,6,alive
    TimerQueue,5,alive,daemon
    ConsoleWriterThread,6,alive,daemon
Group http://xxxx.xxxx.xxxxx.xx:8001/OA_JAVA/-threadGroup,ac=13,agc=0,pri=4
    Applet 1 LiveConnect Worker Thread,4,alive
    AWT-EventQueue-2,4,alive
    thread applet-oracle/apps/fnd/formsClient/FormsLauncher.class-1,4,alive
    Applet 2 LiveConnect Worker Thread,4,alive
    thread applet-oracle.forms.engine.Main-2,4,alive
    Forms-StreamMessageReader,4,alive
    Forms-StreamMessageWriter,4,alive
    HeartBeat,4,alive
    Busy indicator,1,alive,daemon
    TaskScheduler timer,4,alive
    CursorIdler,4,alive
    Thread-14,4,alive
    Flush Queue,4,alive
Done.

所以,有三个 AWT-EventQueue线程...现在的问题是:如何查询/检索正确的线程,以及如何使Runnable传递给invokeLater在"好线程"中运行(我想最好的一个是最后一个(AWT-EventQueue-2)

推荐阅读
臭小子
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有