return thd ptr on init, add thd terminate support