Overview
| Artifact ID: | ce2c4b8ed4ec25b5ebbbeda9ec401fdeda72fbe7 |
|---|---|
| Ticket: | 416643ffffffffffffffffffffffffffffffffff
rand() has identical results in threads. |
| User & Date: | davygrvy on 2001-04-17 11:27:49 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
This is having difficulty on windows. Isn't the c- runtime supposed to handle this situation just fine? I'm perplexed by this: package require Thread foreach a {1 2 3 4 5 6} { set threads($a) [thread::create { proc doit {} { puts [expr {rand()}] }; thread::wait }] } foreach a {1 2 3 4 5 6} { thread::send -async $threads($a) doit } foreach a {1 2 3 4 5 6} { thread::send -async $threads($a) thread::exit } C:\Program Files\Tcl\bin>tclsh84t % source test.tcl % 0.0541875106535 0.0541875106535 0.0541875106535 0.0541875106535 0.0541875106535 0.0541875106535 I really don't think this is a Tcl inherit to Tcl, but does show an interesting behavior. Changing the run to be syncronous got this: package require Thread foreach a {1 2 3 4 5 6} { thread::create { puts [expr {rand()}] } } % source test.tcl 0.11639496317 0.366838779471 0.366838779471 0.484234318363 0.609456226513 % 0.726851765405 The docs state "Each interpreter has it's own seed." on the expr man page, but I tend to disagree after seeing the above. Where's the seeding happening? Should Tcl_CreateInterp() do the seeding? - foundin changed to: "obsolete: 8.4a2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "davygrvy"
- subsystem changed to: "49. Threading"
- title changed to: "rand() has identical results in threads."
- type changed to: "Bug"