Constants and thread safety

  • Thread starter Thread starter paul.hester
  • Start date Start date
P

paul.hester

Hi all,

All of the classes in my DAL are static, with constants defining the
stored procedures and parameters. I've been having some problems with
my site which makes me wonder if there's a thread safety issue.

Are consts thread safe? Would the following example create any thread
safety issues? Would you recommend using static readonly members
instead of constants?

public static class Test
{
private const string TEST_ME = "test";

public static void DoSomething()
{
AnotherStaticClass.DoSomethingElse(TEST_ME);
}
}

Thanks,

Paul
 
Hi Paul,

Constants are thread safe - I've been using them that way forever.

The example you're showing here doesn't have any thread issues associated
with it that I can see.

(Tell Greg & everyone, that I said hello...)
 
Back
Top