Don't fail 050-sync-test due to thread timing

Currently, there is a thread execution possible wherein the sleepy
thread, even though it has a longer wait, finishes before the pesky thread,
and hence prints an output which is not expected, even if the
synchronization primitives are working fine.
In this change we let sleepy thread wait in a loop until pesky thread is
not done. This way the unexpected output is printed only if interrupt()
fails to interrupt sleepy thread.

Bug: 117597114
Test: art/test/testrunner/testrunner.py --target --gcstress --debug -t
050-sync-test

Change-Id: I4fc3afb40ac11e413174391419eaad39e80c8b10
2 files changed