KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose there is a function (member function possibly) SomeType foo() { static SomeType var = generateVar(); return var; } How var will be initialised if foo will be called 'for first time' from multiple threads simultaneously? Is it guaranteed that generateVar() will be called only once in any scenario (if used of course)? Is it guaranteed that foo will return the same value when called multiple times in any scenario? Is there a difference in behaviour for primitive or non-primitive types?
Tags (comma-separated)
Save Edits
Cancel