make Compile() thread safe