考虑我有一个共享功能:-
Public Shared Function CalculateAreaFromRadius(ByVal radius As Double) As Double
' square the radius...
Dim radiusSquared As Double
radiusSquared = radius * radius
' multiply it by pi...
Dim result As Double
result = radiusSquared * Math.PI
'Wait a bit, for the sake of testing and
'simulate another call will be made b4 earlier one ended or such
for i as Integer = 0 to integer.Max
Next
' return the result...
Return result
End Function
我的问题:
如果我在同一个 vb .net 应用程序中有两个或多个线程,并且每个线程同时使用不同的 RADIUS 调用共享函数,他们每个人都会得到自己的 AREA 吗?
我想知道函数的每次调用是否使用相同的局部变量,或者每次调用都会创建局部变量的新实例?
如果我有多个 (2+) 单线程应用程序并且它们都以不同的 RADIUS 值同时调用该函数,上述问题的答案是否相同?
我会很感激你的回复。谢谢你。