how does threads work