multithreading - Singletons in multi threaded environment -


when using singletons, if class has instance fields should careful when several threads might using singleton? (and fields mutable , values can changed)

i havn't tried in theory seems answer yes , need synchronization (or skip singleton)

when access object (or same mutable data) multiple threads (or processes) need kind of synchronization. there no difference whether singleton or other "non-singleton" object.

one additional question, in case of singletons creation of singleton though, if created first time used, first time might concurrently different threads, need synchronize singleton-creation well.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -