How to define local static variables (that keeps its value between function calls) that are not shared among different threads?
I am looking for an answer both in C
Just use static and __thread in your function.
Example:
int test(void) { static __thread a; return a++; }