add support for detached threads