Prevent a deadlock if ThreadedResolver resolves a unicode hostname at module-import time.

Updated version of https://github.com/facebook/tornado/pull/955, but solves the issue differently. To see the problem this solves, try:
````
PYTHONPATH=. python -c "import tornado.test.resolve_test"
````
Without the patch to ThreadedResolver, that import hangs.

I first discovered this in the process of [debugging a PyMongo issue](https://jira.mongodb.org/browse/PYTHON-607); Gevent had a deadlock and I found that Tornado is susceptible to the same bug.