Bug Description

This bug was originally filed by Norberto Leite in the gearman-ij project. Refilling it here ....

Hi there,

The GearmanClientImpl class has a bug on method getSessionForTask() when trying to collect a random value for the list of possible gearmanSession on the list. This line :
int s = (int) Math.round((Math.random() * (sessions.size() - 1)));
I have been testing this and it provides not "very random" at all.(most common value is 0!).

I recommend the use of :
Random rand = new Random(System.currentTimeMillis());
int s = rand.nextInt(sessions.size());

There's a relative gain in performance and more decoupled organization of code without the need to use static functions:
(100000000 iterations loop)
Random -> 2287 mls