[Mono-devel-list] Thread Safety Question

David Hardin david.hardin at alaskaair.com
Wed Mar 12 19:08:32 EST 2003


Why is code such as:

	public sealed class DefaultAuthenticationModule : IHttpModule
	{
		static GenericIdentity defaultIdentity = new GenericIdentity ("", "");
		...
		void OnDefaultAuthentication (object sender, EventArgs args)
		{
			...
			if (context.User == null)
				context.User = new GenericPrincipal (defaultIdentity, new string [0]);
		}
	}

thread safe when Microsoft's documentation states:

	GenericIdentity Class

	Thread Safety
		Any public static (Shared in Visual Basic) members of
		this type are safe for multithreaded operations. Any
		instance members are not guaranteed to be thread safe.

Based on the documentation how do I know what is and isn't thread safe?
Clearly there will be a lot of GenericPrincipals out there pointing at the
same GenericIdentity.  Example code I've seen for working with the
GenericPrincipal isn't synchronizing access to the Identity so will such
code blow up?

Thanks...




More information about the Mono-devel-list mailing list