是MSVC的时间函数是线程安全的? [英] Are the time functions of MSVC thread-safe?

查看:127
本文介绍了是MSVC的时间函数是线程安全的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux的情况下,对时间的函数,我们有一个_r版本例如:本地时间有则localtime_r,但在Windows我无法找到一些这样的功能。是Windows时间函数本质上就是线程安全的吗?

In case of Linux, for time functions we have a _r versions Ex: localtime has localtime_r, but in Windows I am unable to find some such functions. Are the Windows time functions inherently thread-safe?

推荐答案

与Microsoft Visual Studio你有一个选择C-运行时的使用方法:通常他们是:

With Microsoft Visual Studio you have a choice of c-runtimes to use: typically they were:


  • 静态单线程库(libc)

  • 静态多线程库(libcmt)

  • 动态多线程库(MSVCRT)

多线程库是线程安全的。单线程库最后一次出现在2005年MSVC并从2008年MSVC已被删除。

The multithreaded libraries are thread safe. The single threaded library was last seen in MSVC 2005 and has been dropped from MSVC 2008.

该DLL运行时(MSVCRT.DLL)只是必须是线程安全的 - 作为实施是一个dll,因此在这个过程中其他多个模块,所有这些都可能使用工作线程之间共享的,它必须是线程安全的因为是设计应用程序以其他方式使用任何理智的方式。

The dll runtime (msvcrt.dll) just has to be thread safe - As the implementation is in a dll and therefore shared between multiple other modules in the process, all of which could be using worker threads, It has to be threadsafe as there would be no sane way to design an application to use it otherwise.

这篇关于是MSVC的时间函数是线程安全的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆