473,226 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

basic threading question

Are function variables thread safe?

def f(a):
# whatever
return float(a)

Is that OK?

def f(a):
#whatever
b=a:
#whatever:
return float(b)

Is that OK?

Steve.
Oct 31 '07 #1
4 979
On Oct 30, 7:58 pm, "bambam" <da...@asdf.asdfwrote:
Are function variables thread safe?

def f(a):
# whatever
return float(a)

Is that OK?

def f(a):
#whatever
b=a:
#whatever:
return float(b)

Is that OK?

Steve.
Huh?

Oct 31 '07 #2
ch************@gmail.com wrote:
On Oct 30, 7:58 pm, "bambam" <da...@asdf.asdfwrote:
>Are function variables thread safe?

def f(a):
# whatever
return float(a)

Is that OK?

def f(a):
#whatever
b=a:
#whatever:
return float(b)

Is that OK?

Steve.

Huh?
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?

Steve.

Oct 31 '07 #3
[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
Oct 31 '07 #4
thanx :~)
Nov 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
4
by: Richard Spooner | last post by:
Hey, I'm very new to python and am trying to do the following. I may get the jargon wrong at times but hopefully you can see what I'm trying to do... I have created a threaded class which...
7
by: asfwa | last post by:
I'm new to C++ and I have some basic questions. I have written an app that does some network stuff in a worker thread. The thread function requests something from the server, gets it and creates...
5
by: John | last post by:
I have an application that scans files and it takes a while to finish. While my application is running if I open other applications, my main application GUI becomes grey....does not refresh or...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
3
by: KC | last post by:
Hey, I'm trying to implement a cancel button in my app (this is after the bulk of the program has been built). To do this I, of course, need to use a thread to run the time consuming method...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
2
by: Chris Ashley | last post by:
Hi, I'm overriding WndProc to process some custom messages like so: protected override void WndProc(ref Message m) { if (m.Msg == ImageFileMsg.MSG_IF_NEW_DATA) { ProcessNewDataMessage(m);
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.