Skip to content

Instantly share code, notes, and snippets.

@b2977053
Created December 19, 2019 08:43
Show Gist options
  • Save b2977053/ecd8107ecc714895711fd8aa112df4dc to your computer and use it in GitHub Desktop.
Save b2977053/ecd8107ecc714895711fd8aa112df4dc to your computer and use it in GitHub Desktop.
internal class 使用同步製作Pizza
{
private static int Pizza總數 = 0;
internal void 開始()
{
var watch = Stopwatch.StartNew();
Console.WriteLine("開始進行製作披薩...");
// 製作10個披薩 993 時間
for (int i = 0; i < 10; i++)
{
同步製作一個披薩();
}
watch.Stop();
Console.WriteLine($"\n\nPizza總數:{Pizza總數}\n共花費:{watch.Elapsed.TotalMilliseconds.ToString("0")} 時間。");
}
public static void 同步製作一個披薩()
{
揉麵團();
發酵();
桿面皮();
放上佐料();
烤披薩();
Pizza總數++;
}
public static void 揉麵團()
{
string status = "揉麵團中...";
Thread.Sleep(30);
status = "揉麵團 完成";
}
public static void 發酵()
{
string status = "發酵中...";
Thread.Sleep(40);
status = "發酵 完成";
}
public static void 桿面皮()
{
string status = "桿面皮中...";
Thread.Sleep(2);
status = "桿面皮 完成";
}
public static void 放上佐料()
{
string status = "放上佐料中...";
Thread.Sleep(2);
status = "放上佐料 完成";
}
public static void 烤披薩()
{
string status = "烤披薩中...";
Thread.Sleep(20);
status = "烤披薩 完成";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment