add CurrentThread info (via namespace)
bugfix CurrentThread not working for main thread
add lock/unlock check according to CurrentThread info