I have an `int array[100]` and I want 5 threads to calculate the sum of all array elements.

Each thread iterates through 20 elements within its dedicated range and writes the sum into a global `sum` variable.

Is a mutex necessary here? There is no synchronization needed since all threads are reading from independent sources.

```
for(i=offset; i<offset+range; i++){
  // not used pthread_mutex_lock(&mutex);
  sum += array[i];
  // not used pthread_mutex_unlock(&mutex);
}

```

Can this lead to unpredictable behavior or does the OS actually handle this?

Is it advisable to leave out the mutex in this case? I've noticed that those algorithms run a lot faster without it.