Possible Duplicate:
Calling Console.WriteLine from multiple threads
Just want to know if multiple threads call Console.WriteLine
, will it cause a deadlock?
Answers. Yes, they are. Although TextWriter methods are not, Console. Out uses a SyncTextWriter which is thread-safe.
Is Debug. WriteLine() thread safe? According to this, it is thread safe.
The StreamWriter documentation has this to say: “Any public static (Shared in Visual Basic) members of this type are thread safe.
WriteLine(String, Object, Object) Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.
It's safe! From the .NET API browser:
Console I/O Streams
[...]
I/O operations using these streams are synchronized, which means multiple threads can read from, or write to, the streams.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With