Add usleep for Thread::Unregister
Prevent possible bad behavior for realtime threads.
Bug: 111277984
Test: make
Change-Id: Ib558a4e1289675f88ef4d999277287e4dd7ed6d3
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index ba333f6..9222024 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -1476,6 +1476,9 @@
list_.remove(self);
break;
}
+ // In the case where we are not suspended yet, sleep to leave other threads time to execute.
+ // This is important if there are realtime threads. b/111277984
+ usleep(1);
}
// We failed to remove the thread due to a suspend request, loop and try again.
}