
Signature
Ross Bamford - rosco@roscopeco.remove.co.uk
> [...] And output in general is _slow_ compared to
> memory operations.
And output to a TTY (in Unix) or to a Windows "console" can be /very/ slow even
compared to I/O in general.
-- chris
Thomas G. Marshall - 04 Nov 2005 22:31 GMT
Chris Uppal coughed up:
>> [...] And output in general is _slow_ compared to
>> memory operations.
[quoted text clipped - 3 lines]
>
> -- chris
Coding from your 110 baud teletype again? ;)

Signature
"His name was Robert Paulson. His name was Robert Paulson. His name was
Robert
Paulson..."
Ross Bamford coughed up:
>> Do frequent System.out calls hamper performance?
>
> Well, System.out is synchronized, so yes, frequent calls will cause
> some bottlenecking.
*ONLY* if there are different threads attempting the system.out.{whatever}at
the same time! It is a slow beast anyway, simply because it is i/o, but you
may be misleading the newbie a little. A synchronized method doesn't block
anything other than what it is synchronizing on, in this case all the
java.io.PrintStream methods synchronize on their own instances.
> If you really overuse it, it's easy to destroy
> any benefits you gain from multithreading. And output in general is
[quoted text clipped - 3 lines]
> System.out call. One common way is to have a buffered writer with
> manual flush, backed by System.out and only flushed every so often.
Ross Bamford - 03 Nov 2005 18:27 GMT
> Ross Bamford coughed up:
>>
[quoted text clipped - 11 lines]
> anything other than what it is synchronizing on, in this case all the
> java.io.PrintStream methods synchronize on their own instances.
True, I should have been clearer that this applies specifically to
multithreaded programs, where System.out is called from different threads.
The time taken to actually obtain a (previously open, obviously)
synchronization lock is vanishingly small, so it's not an _automatic_
performance hit (that comes from the IO ;))
Apologies for the confusion.

Signature
Ross Bamford - rosco@roscopeco.remove.co.uk