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
Post a Comment