悬赏园豆:5
[已解决问题]
解决于 2008-04-13 16:59
<P>下面是段测试代码,大致的功能是,网页调用一个类的静态方法,在静态方法里,对i这个变量进行2次赋值。疑问是,如果多个网页调用此方法,会不会相互干扰呢?</P>
<P>试验结果表明并不相互干扰,很是困惑。</P>
<P>public partial class Default2 : System.Web.UI.Page<BR>{<BR> protected void Page_Load(object sender, EventArgs e)<BR> {<BR> Response.Write(Class1.Fun1(DateTime.Now.ToLongTimeString()).ToString());<BR> }</P>
<P>}</P>
<P>public class Class1<BR> {<BR> public static int Fun1(string message)<BR> {<BR> int i = 0;<BR> LogHelper.Info(message+"Fun1 step1 i="+i.ToString()+" and to sleep 5sec");<BR> Thread.Sleep(5000);<BR> <BR> i = 2;<BR> LogHelper.Info(message + "Fun1 step2 i=" + i.ToString() + " and to sleep 5sec");<BR> Thread.Sleep(5000);<BR> LogHelper.Info(message + "Fun1 over i=" + i.ToString() + " ");<BR> return i;<BR> }</P>
<P> }</P>