basic threading question

Bryan Olson fakeaddress at nowhere.org
Wed Oct 31 05:33:48 EDT 2007


[david] wrote:
> If I have 37 threads, all calling a large function 'f', are the formal 
> parameters thread safe?
> 
> That is, will the formal parameters be trashed?  Do you need to use 
> locks or semaphores before using formal parameters? Are the labels for
> formal parameters static?
> 
> If I have 73 threads, all calling a large function 'f', are the local 
> values thread safe? Does each thread maintain it's own stack? Are the 
> labels for local values stack-based?

Yes. Each thread has its own stack, and that's where the parameter
bindings live.

Of course if you pass the same mutable object in multiple threads,
that's a different issue.


-- 
--Bryan



More information about the Python-list mailing list