realize thread safe