Fix visibility race which sometimes prevented inputs to start.

Convert previousLifecycle to an AtomicReference to ensure visibility
across threads. Also use Lifecycle.UNINITIALIZED instead of null as
initial state.

With help from @kroepke.