If you need to shuffle a sequence you should consider std::random_shuffle
(or std::shuffle
in C++11). It reorders the elements in a sequence so that each possible permutation of those elements has equal probability of appearance. Yes, it can be used with arrays, not just vectors. Anything that is a "range".
Now going back to your code you have a problem with the seeding. The algorithms that generate (pseudo-)random numbers take an initial value, that is the seed. Giving the same seed they produce the same sequence of numbers. That means you only have to seed the random number generated once (per thread), otherwise you will produce the same sequence of numbers again and again. In this loop of yours you get the same number for a while, until the time changes an a new value for the seed is used.