----------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
public partial class Default8 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// 设置 Session
Session["IsLogin"] = true;
List lst = new List();
for (int i = 0; i < 5; i++)
{
Thread t = new Thread(new ThreadStart(DoWork));
t.Name = string.Format("Thread-{0}", i);
lst.Add(t);
}
foreach (Thread t in lst)
{
t.Start();
}
}
private void DoWork()
{
while (true)
{
if (Session["IsLogin"] != null)
{
Boolean IsLogin = (Boolean)Session["IsLogin"];
}
String CurrentThreadName = Thread.CurrentThread.Name;
Thread.Sleep(1000);
}
}
}