concurrency - Are C# structs thread safe? -



concurrency - Are C# structs thread safe? -

is c# struct thread-safe?

for illustration if there a:

struct info { int _number; public int number { { homecoming _number; } set { _number = value; } } public data(int number) { _number = number; } }

in type:

class daddata { public info thedata { get; set; } }

is property named thedata, thread-safe?

no, structures in .net not intrinsically thread-safe.

however, copy-by-value semantics structures have great relevance converation.

if passing structures around , assigning them in way variables or pass-by-value parameters (no ref or out keywords) copy beingness used.

of course, means changes made re-create not reflected in original structure, it's aware of when passing them around.

if accessing construction straight in manner doesn't involve copy-by-value semantics (e.g. accessing static field type of structure, , marc gravel points out in answer, there many other ways) across multiple threads, have take business relationship thread-safety of instance.

c# concurrency struct thread-safety parallel-processing

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -