Ho lasciato perdere..

pthread_create(&threadId[x], NULL, (void*)&eseguiQuery, (int*)a[n]);

e via