print statement and multithreading

Quasimodo KILLzdramboSPAMMERS at zdnetmail.com
Tue Aug 22 13:01:42 EDT 2000


Yes, at least on Windows98 it does.  However if mulitple threads are
printing simultaneously you might get the output interlaced.

x='456'
y='EFGH'

e.g. thread1 prints "123", x
  thread 2 prints "ABCD", y

You might get something like this if they try print (almost) simultaneously:

>>> 123 ABCD 456
        EFGH

or any other combination of the above.  The only way I've been able to get
around this (for now, not sure if it will hold true) is to assign the entire
print output to a temp var and then print:

e.g.  temp = "123 " + x     #i.e. temp is now:  "123 456"
         print temp

Maybe someone else knows a better way.

HTH,

Jose


"Roy Katz" <katz at Glue.umd.edu> wrote in message
news:Pine.GSO.4.21.0008211956340.4433-100000 at z.glue.umd.edu...
> Hi.
>
>
> Does the print statement cause output to be displayed
> when it is run from threads, as opposed to the main
> thread?
>
>
>
> Thanks,
>
> Roey Katz.
>





More information about the Python-list mailing list