Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is console.writeline thread safe? [duplicate]

Possible Duplicate:
Calling Console.WriteLine from multiple threads

Just want to know if multiple threads call Console.WriteLine, will it cause a deadlock?

like image 223
user496949 Avatar asked Jan 27 '11 03:01

user496949


People also ask

Is console WriteLine thread safe?

Answers. Yes, they are. Although TextWriter methods are not, Console. Out uses a SyncTextWriter which is thread-safe.

Is debug WriteLine thread safe?

Is Debug. WriteLine() thread safe? According to this, it is thread safe.

Is StreamWriter WriteLine thread safe?

The StreamWriter documentation has this to say: “Any public static (Shared in Visual Basic) members of this type are thread safe.

What is use of console WriteLine () method?

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.


1 Answers

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.

like image 195
ClosureCowboy Avatar answered Oct 16 '22 14:10

ClosureCowboy