If you have only a single thread, seed once. If you reseed often, you might actually break some of the statistical properties of the random numbers. If you have multiple threads, don't use rand
at all, but rather something threadsafe like drand48_r
, which lets you maintain a per-thread state (so you can seed once per thread).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…