### Question:
AndroidSchedulers { public static Scheduler mainThread() { return RxAndroidPlugins.onMainThreadScheduler(MAIN_THREAD); } private  AndroidSchedulers(); static Scheduler mainThread(); static Scheduler from(Looper looper); @SuppressLint("NewApi") // Checking for an @hide API. static Scheduler from(Looper looper, boolean async);  }### Answer:
@Test public void mainThreadCallsThroughToHook() { final AtomicInteger called = new AtomicInteger(); final Scheduler newScheduler = new EmptyScheduler(); RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() { @Override public Scheduler apply(Scheduler scheduler) { called.getAndIncrement(); return newScheduler; } }); assertSame(newScheduler, AndroidSchedulers.mainThread()); assertEquals(1, called.get()); assertSame(newScheduler, AndroidSchedulers.mainThread()); assertEquals(2, called.get()); }
@Test public void mainThreadAsyncMessagesByDefault() { ShadowLooper mainLooper = ShadowLooper.getShadowMainLooper(); mainLooper.pause(); ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue()); Scheduler main = AndroidSchedulers.mainThread(); main.scheduleDirect(new Runnable() { @Override public void run() { } }); Message message = mainMessageQueue.getHead(); assertTrue(message.isAsynchronous()); }