On API level 28(Pie) a new method is introduced in the Context class to get Executor for the main thread getMainExecutor().
Context
How to get this executor on API
You can use (in activity for example):
ContextCompat.getMainExecutor(this);
https://developer.android.com/reference/androidx/core/content/ContextCompat.html#getMainExecutor(android.content.Context)