I use the int array.
I use that method to fill indexes in array.
public void makeSelectionOfGivenNumber(int number) throws InterruptedException
{
if (this.table[number]!= 0)
{
int multiple;
multiple = number + number;
while (multiple <= upperRange)
{
this.table[multiple] = 0;
multiple += number;
}
}
}
For example, one thread starts from 2 and eliminates all multiples, a second thread starts from 5 and makes the same activities. In some case the simultaneously the value in index 10 (in both cases are multiples). How to use in this case semaphores or other tools to lock that only one thread has access on particular index, not the whole array. I want that these two threads would work in parallel on the same table.
AtomicIntegerArraymight be enough for this.