Prevent the thread from causing IllegalStateException