Move wait() to jthread implementation