本文介绍了是Delphi全局程序线程安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果两个或多个线程调用标准的Delphi / Pascal过程(而不是对象的方法),那么这个线程安全性是不是没有实例数据,只是过程中的局部变量。 >
我的猜测是,一个线程使用的本地存储可能会被另一个线程损坏。

If two or more threads call a standard Delphi/Pascal procedure (not a method of an object), is this threadsafe ? There is no instance data, just local variables in the procedure.
My guess is that the local storage being used by one thread could be corrupted by the other thread.

推荐答案

堆栈中维护本地存储,每个线程都是唯一的。如果没有全局数据被程序操纵,这是安全的。

Local storage is maintained on the stack, which is unique to each thread. If no global data is being manipulated by the routine, it is safe.

这篇关于是Delphi全局程序线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:38