It is fine to use the same function as a thread entry point for multiple threads.
However, from the posted code the address of i
is being passed to both threads. If either thread modifies this memory and the other reads then there is a race condition on i
. Without seeing the declaration of i
it is probably a local variable. This is dangerous as the threads require that i
exist for their lifetime. If i
does not the threads will have a dangling pointer. It is common practice to dynamically allocate thread arguments and have each thread free its arguments.