Uncertain. Originally Scottish; probably onomatopoeic, but compare Middle English thakken, from Old English þaccian (whence Modern thwack by conflation with whack). Sense 6 of the verb is likely a semantic loan from Malay hentam (“to strike; to do something carelessly”).