C
cristalink
The below is perfectly OK in C++, but I wonder how safe is it C#. There are
cases when one thread is writing to, another one is reading from the same
variable. I don't want/need to synchronize the access.
My question is, can the .NET framework handle this scenario, or it may throw
an exception? I realize the data may be out of sync (say, a half of the
variable contains new data, another half contains old data), but it's not an
issue.
Thanks
uint64 var = 0;
thread1_Write()
{
while(true)
{
var = random();
}
}
thread2_Read()
{
while(true)
{
Console.Write("{0}", var);
}
}
cases when one thread is writing to, another one is reading from the same
variable. I don't want/need to synchronize the access.
My question is, can the .NET framework handle this scenario, or it may throw
an exception? I realize the data may be out of sync (say, a half of the
variable contains new data, another half contains old data), but it's not an
issue.
Thanks
uint64 var = 0;
thread1_Write()
{
while(true)
{
var = random();
}
}
thread2_Read()
{
while(true)
{
Console.Write("{0}", var);
}
}
