Thread detection