Reputation: 1665
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.
Upvotes: 5
Views: 812
Reputation: 12837
if only local vars you should be ok. if I were you I would test that theory: declare a local variable in the proc and increment it a million time in a loop, then call the proc from two threads and check the value of the variable after the million increments.
Upvotes: 0
Reputation: 84590
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.
Upvotes: 9