Writeln in threads

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Writeln in threads

Ryan Joseph
Is writeln thread safe? I’m getting some strange crashes and I’m curious if they’re related to calling writeln on multiple threads.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Writeln in threads

fredvs
> Is writeln thread safe?

In console application, IMHO yes.

But If you use writeln in a Windows environnement or with LCL widget, it could not be safe.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Writeln in threads

Jonas Maebe-3
In reply to this post by Ryan Joseph
On 17/02/17 12:43, Ryan Joseph wrote:
> Is writeln thread safe? I’m getting some strange crashes and I’m curious if they’re related to calling writeln on multiple threads.

Unlikely. The output from different threads can be mixed at weird places
since it all goes to the same file handle and buffer flushes can
interleave, but every thread gets its own copy of the standard IO buffer
structures.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal