add compile single template, make compilation thread-safe