How to define thread-local local static variables?

前端 未结 5 451
执笔经年
执笔经年 2020-12-09 16:48

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

5条回答
  •  温柔的废话
    2020-12-09 17:01

    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.

    The next version of the C standard adds threads and has a concept of thread local storage.

提交回复
热议问题