export thread control to generated wrappers
Merge pull request #3511 from mattip:2.4