Skip to content

Commit b34fe4f

Browse files
committed
Thread-safe version Singleton: fixes
1 parent 02c7a55 commit b34fe4f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Singleton.Conceptual/ThreadSafe/Program.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,23 @@ static void Main(string[] args)
7474
"RESULT:"
7575
);
7676

77-
Thread process1 = new Thread(() => {
77+
Thread process1 = new Thread(() =>
78+
{
7879
TestSingleton("FOO");
7980
});
80-
Thread process2 = new Thread(() => {
81+
Thread process2 = new Thread(() =>
82+
{
8183
TestSingleton("BAR");
8284
});
85+
8386
process1.Start();
8487
process2.Start();
88+
89+
process1.Join();
90+
process2.Join();
8591
}
8692

87-
static public void TestSingleton(string value)
93+
public static void TestSingleton(string value)
8894
{
8995
Singleton singleton = Singleton.GetInstance(value);
9096
Console.WriteLine(singleton.GetValue());

0 commit comments

Comments
 (0)