Avoiding Thread.sleep() when thread is exiting

Change-Id: Idf71e71d176395258fe1297dcd366b586d5d40fd
Merge "Avoiding Thread.sleep() when thread is exiting"