add thread-safety check in debug build