Forum Navigation
Stdout is not thread-safe?
Moderators:
kris
Posted: 09/17/08 16:54:02I use dmd 1.035 and tango 0.99.7 to write the follwing code to try thread. It could be compiled, but when I run it, it would crash and show the following message:
tango.core.Exception.AssertException@D:\Development\DTango\bin\..\import\tango\io\Buffer.d(833): Assertion failureI found Buffer.d and jump to line 833, which is
assert (index <= extent);Is this a bug? Because I believe basic output function like this should be thread-safe.
Here is code I wrote:
import tango.io.Stdout; import tango.core.Thread; void eventHandler () { while (true) { Stdout ("Hello World!").newline.flush; } } void eventHandler2 () { while (true) { Stdout ("Goodbye World!").newline.flush; } } void main (char [][] args) { Thread handler1 = new Thread (&eventHandler); Thread handler2 = new Thread (&eventHandler2); handler1.start(); handler2.start(); return; }-- Brian Hsu