Add a thread debugging flag TDB_BOUNDARY
Tested by: pho
(cherry picked from commit f0592b3c8dd8e172f0e7165c11371108d4d8838d)