void (final boolean withAutoreleasePool, final boolean waitUntilDone, final Runnable runnable) { String runnableCountString; synchronized (RUNNABLE_LOCK) { initRunnableSupport(); runnableCountString = String.valueOf(++ourCurrentRunnableCount); ourMainThreadRunnables.put(runnableCountString, new RunnableInfo(runnable, withAutoreleasePool)); } // fixme: Use Grand Central Dispatch instead? final ID ideaRunnable = getObjcClass("IdeaRunnable"); final ID runnableObject = invoke(invoke(ideaRunnable, "alloc"), "init"); final ID keyObject = invoke(nsString(runnableCountString), "retain"); invoke(runnableObject, "performSelectorOnMainThread:withObject:waitUntilDone:", createSelector("run:"), keyObject, Boolean.valueOf(waitUntilDone)); invoke(runnableObject, "release"); }