Merge "Revert "Revert "Improve the thread flip."""
am: 0b10387ced

Change-Id: I4695d621868558df12e072bf7055a9f78e752b58