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
The current C standard has no model for threads or alike, so you can't get an answer, there.
The utility foreseen by POSIX for that is pthread_[gs]etspecific.
pthread_[gs]etspecific
The next version of the C standard adds threads and has a concept of thread local storage.