C
CJ
I came across the ThreadStatic attribute today, but I'm a bit confused
by it.
I understand that it makes a variable static to a particular thread,
so each thread will have it's own value for it (unlike a regular
static variable). But then what makes it different to just an
ordinary class level variable? In other words, what's the difference
between var1 and var2 below?
public class Test
{
[ThreadStatic]
public static int var1;
public int var2;
}
by it.
I understand that it makes a variable static to a particular thread,
so each thread will have it's own value for it (unlike a regular
static variable). But then what makes it different to just an
ordinary class level variable? In other words, what's the difference
between var1 and var2 below?
public class Test
{
[ThreadStatic]
public static int var1;
public int var2;
}