Fix thread shutdown race in adbconnection

In cases where the runtime shuts down cleanly (i.e. returns from the
`int main(String[])` method) the adbconnection poll thread could race
runtime shutdown and potentially crash. Since clean runtime shutdown
is rare in android this issue was not often observed. To fix this we
moved the shutdown of the adbconnection threads to earlier, when the
runtime is still able to process thread-detach and join the poll
thread. This ensures that (1) the shutdown process will wait for all
thread operations before starting to tear down the thread system and
(2) we won't leave any orphan pthreads around.

Bug: 151801489
Bug: 149494762
Test: On a blueline:
      $ dalvikvm64 -cp /data/local/tmp/classes.dex -XjdwpProvider:adbconnection Main
Change-Id: I38bfeb7edc58d950381bca42ff2ecec53de65ae0
1 file changed