Using a decorator to facilitate switching between main and background threads.[1]