Bug 24430. Bug 24663.  Add thread support.
Merge branch 'mainline'