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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -