天天看點

localtime和localtime_r

在寫代碼的時候,經常會用到讀取系統時間的函數。localtime函數不是線程安全的。如果在多線程裡調用localtime函數,很可能會出現問題。

多線程應用裡面,應該用localtime_r函數替代localtime函數,因為localtime_r是線程安全的。

struct tm *localtime(const time_t *clock);

struct tm* localtime_r( const time_t* timer, struct tm* result );

原文:

http://langkes.blog.163.com/blog/static/3959176420122281102620/

上一篇: wget簡單使用
下一篇: curl簡單使用

繼續閱讀