It is necessary to synchronize the Console.WriteLine calls?

J

Jon Skeet [C# MVP]

Naldo Alcalde said:
Env: W2k, VS2005 Std

Hi everybody, I have a application with threads writing simultaneously
to the console with WriteLine. It is necessary the synchronization? I read
http://msdn2.microsoft.com/en-us/library/system.console(VS.80).aspx but I
had a deadlock in this function with 2 threads.

I find it very unlikely that you actually had a deadlock using
System.Console. However, if you did, I'm sure MS would be very
interested in knowing about it, as it would probably be a bug, given
that the documentation says it's thread-safe.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

AFAIK it's thread safe. Almost all the articles,examples and code snipes you
find explaining multithreading you see Console.WriteLine() to show how the
different threads execute.

It could be a bug in 2.0 though.

An example will be interesting.
 
N

Naldo Alcalde

Sorry but that problem has not happenned again.

Jon Skeet said:
I find it very unlikely that you actually had a deadlock using
System.Console. However, if you did, I'm sure MS would be very
interested in knowing about it, as it would probably be a bug, given
that the documentation says it's thread-safe.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Top