Tidy OldSocketTest.test_connectLjava_net_SocketAddressI_setSOTimeout.

Improve thread safety and exception handling.

I don't expect this will fix the test flakiness but it eliminates
these as possibilities.

Bug: 144258500
Test: atest --iterations 10 CtsLibcoreTestCases:libcore.java.net.OldSocketTest
Change-Id: Idfa01771afa562482fcfd597abac325f95fe183a
(cherry picked from commit 282ba2d764a259731816682dedf080edbe28db18)
1 file changed