473,288 Members | 1,743 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,288 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 983
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. ...
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.