4 ms·
Slide #33: Fan-in using select I always get alternating Joe/Ann responses. I'm not seeing that in the code though. It says selectors are chosen pseudo-randomly
by jws 14y ago
Slide #33: Fan-in using select
I always get alternating Joe/Ann responses. I'm not seeing that in the code though. It says selectors are chosen pseudo-randomly. I'm expecting Joe or Ann to get a couple quickies in at some point.
- jws 14y agoI seen the RNG get seeded in later examples. This may just be an unseeded RNG and an unfortunate sequence that gives an illusion of an order.
- Cyranix 14y agoIf you added a trivial wait of random length before each response, mightn't you see non-alternating behavior at times?
- gizzlon 14y agoNot GP, but I also saw this.. Increasing the timeout to 0><10 seconds does give the expected output.. But shouldn't I see this from time-to-time with 1 second as well? Hmm..
- gizzlon 14y agoMy rand.Intn() was always returning the same value. Seem like you have to to seed it manually (once, in main() for example): rand.Seed( time.Now().UTC().UnixNano()) http://stackoverflow.com/questions/12321133/golang-random-number-generator-how-to-seed-properly http://stackoverflow.com/questions/12321133/golang-random-nu... Edit: It's in the documentation, but you have to look for it. "Seed uses the provided seed value to initialize the generator to a deterministic state. If Seed is not called, the generator behaves as if seeded by Seed(1)"