in my opinion the provided code above is not thread safe any more:
in the previous solution you had to instatiate a new object of SharedLogger and the method Write existed once for every object.
Now you just have one Write method, which is used by all threads, example:
thread 1:
SharedLogger.Write("Thread 1")
thread 2:
SharedLogger.Write("Thread 2");
public static void Write(string s)
{
// thread 1 is interrupted here <=
lock (_lock)
{
_writer.Write(s);
}
}
correct me when I am wrong ...