Add comment about thread-safeness
Switch to use std::atomic