LWCToolkit.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:openjdk9 作者:
/**
 * Kicks an event over to the appropriate event queue and waits for it to
 * finish To avoid deadlocking, we manually run the NSRunLoop while waiting
 * Any selector invoked using ThreadUtilities performOnMainThread will be
 * processed in doAWTRunLoop The InvocationEvent will call
 * LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual
 * run loop. Does not dispatch native events while in the loop
 */
public static void invokeAndWait(Runnable runnable, Component component)
        throws InvocationTargetException {
    Objects.requireNonNull(component, "Null component provided to invokeAndWait");

    long mediator = createAWTRunLoopMediator();
    InvocationEvent invocationEvent =
            new InvocationEvent(component,
                    runnable,
                    () -> {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    },
                    true);

    AppContext appContext = SunToolkit.targetToAppContext(component);
    SunToolkit.postEvent(appContext, invocationEvent);
    // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
    SunToolkit.flushPendingEvents(appContext);
    doAWTRunLoop(mediator, false);

    checkException(invocationEvent);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号