HDFS-5642: add thread support, WIP.