gpt4 book ai didi

c# - Eric Lippert 和 Neal Gafter C# 谜题

转载 作者:IT王子 更新时间:2023-10-29 03:57:41 24 4
gpt4 key购买 nike

<分区>

这个谜题是在 NDC 2010 上展示的。那里有指向视频的链接,但都已损坏。我不明白这个程序的行为;为什么会挂起?

class Woot
{
private static float PI;
private static bool initialized = doInitialize();

private static bool doInitialize()
{
if (!initialized)
{
var thread = new Thread(() => { PI = 3.14f; });
thread.Start();
thread.Join(); // here
}
return true;
}

public static void Main(string[] args)
{
Console.WriteLine(PI);
}
}

What is the output of this program? Is it:

  • 3.14
  • 0
  • Throws exception
  • None of the above

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com