That's the reason why I have to wake up main thread.
The golden rule #1: GUI thread is never let sleep/block/wait.

By following this rule you never get trapped with the situation like you have. Following this rule itself is thinking about the cost of future being rescued and proactive prevention of need in that.