此線程安全嗎?此線程安全嗎?
private static bool close_thread_running = false;
public static void StartBrowserCleaning()
{
lock (close_thread_running)
{
if (close_thread_running)
return;
close_thread_running = true;
}
Thread thread = new Thread(new ThreadStart(delegate()
{
while (true)
{
lock (close_thread_running)
{
if (!close_thread_running)
break;
}
CleanBrowsers();
Thread.Sleep(5000);
}
}));
thread.Start();
}
public static void StopBrowserCleaning()
{
lock (close_thread_running)
{
close_thread_running = false;
}
}
爲什麼我在想馬拉松人? – Lunatik 2009-12-15 13:47:08