473,794 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the function is not thread-safe? what does it means?

hallo,
what does it means "the function is not thread-safe"?
thak you in advance,
Mario.
May 27 '07 #1
10 3732
_mario.lat skrev:
hallo,
what does it means "the function is not thread-safe"?
thak you in advance,
Mario.
try http://en.wikipedia.org/wiki/Thread-safety for details, and negate
the answer :D
May 27 '07 #2
"_mario.lat " wrote:
what does it means "the function is not thread-safe"?
Think of a thread as a synonym for process. A process is not a program and
vice versa. There are things called "fork" and "join" where a second process
can be _spawned_. Ordinary simple programs, such as a student writes have
only a single thread or process, so the constraint would not be limiting or
interesting. But such programs are at the lower limit of complexity, at
least in this dimension.
May 27 '07 #3
On Sun, 27 May 2007 05:24:22 -0700, "osmium" <r1********@com cast.net>
wrote in comp.lang.c:
"_mario.lat " wrote:
what does it means "the function is not thread-safe"?

Think of a thread as a synonym for process.
Why? It is an incomplete and inadequate definition, and it does not
agree with the C standards's definition of "thread".

Oh, wait a minute, there is no C standard definition of "thread".

So why are you spewing incorrect, off-topic rubbish?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
May 27 '07 #4
_mario.lat wrote:
hallo,
what does it means "the function is not thread-safe"?

The abstract C machine discussed here, don't have concurrent threads
executing. If a function depend on shared data, it will not be thread-safe
and the final result will be unpredictable in a multi-threaded program.

Check the comp.programmin g.threads FAQ for details.

--
Tor <torust [at] online [dot] no>

May 27 '07 #5
"Jack Klein" wrote:
On Sun, 27 May 2007 05:24:22 -0700, "osmium" <r1********@com cast.net>
wrote in comp.lang.c:
>"_mario.lat " wrote:
what does it means "the function is not thread-safe"?

Think of a thread as a synonym for process.

Why? It is an incomplete and inadequate definition, and it does not
agree with the C standards's definition of "thread".

Oh, wait a minute, there is no C standard definition of "thread".

So why are you spewing incorrect, off-topic rubbish?
Number 1. Because it's an immoderate group and I wanted to. Is that so
hard to figure out? Or was it a rhetorical question? The OP may get more
and better help out of the link appended here, it is more complete.

Number 2. I thought the Wikipedia link he was given was remarkably
unhelpful, IIRC it started talking about threads without saying what a
thread is. I thought what I said might possibly be more helpful than
harmful. Since about 70% of the threads on this and c.l.c++ groups are
about off-topicness, do not top post, snip signatures, do not snip
attributions, signatures must be introduced by --, no more than four lines
on a signature, read the FAQ, this is off topic, and general net etiquette I
thought what I said was at least related to computers rather than a medium
for talking about computers. Do you suppse writers spend countless hours
discussing the merits of different pencils and papers? "Spew" sounds like
an unfriendly word to me so I will wish you good day.

http://en.wikipedia.org/wiki/Reentrant
May 27 '07 #6
"osmium" <r1********@com cast.netwrites:
"Jack Klein" wrote:
>On Sun, 27 May 2007 05:24:22 -0700, "osmium" <r1********@com cast.net>
wrote in comp.lang.c:
>>"_mario.lat " wrote:
what does it means "the function is not thread-safe"?

Think of a thread as a synonym for process.

Why? It is an incomplete and inadequate definition, and it does not
agree with the C standards's definition of "thread".

Oh, wait a minute, there is no C standard definition of "thread".

So why are you spewing incorrect, off-topic rubbish?

Number 1. Because it's an immoderate group and I wanted to. Is that so
hard to figure out? Or was it a rhetorical question? The OP may get more
and better help out of the link appended here, it is more complete.
You *wanted* to spew incorrect, off-topic rubbish? I doubt that.
Number 2. I thought the Wikipedia link he was given was remarkably
unhelpful, IIRC it started talking about threads without saying what a
thread is.
In the Wikipedia article titled "Thread-safe", the first use of the
word "thread" is a link to the article on threads.
I thought what I said might possibly be more helpful than
harmful. Since about 70% of the threads on this and c.l.c++ groups are
about off-topicness, do not top post, snip signatures, do not snip
attributions, signatures must be introduced by --, no more than four lines
on a signature, read the FAQ, this is off topic, and general net etiquette I
thought what I said was at least related to computers rather than a medium
for talking about computers. Do you suppse writers spend countless hours
discussing the merits of different pencils and papers? "Spew" sounds like
an unfriendly word to me so I will wish you good day.
<OT>
In the abstract, "threads" and "processes" are very similar; they're
things that concurrently execute code. But in the real-world
situation that the OP is probably interested in, they're very
different things. In Unix-like systems, for example, processes are
created by calling fork(); threads are created by pthread_create (or
perhaps by some routine in some other thread library). A single
process can contain multiple threads, not vice versa.
</OT>

Yes, your response did have the virtue of being related to computers,
but it was off-topic, factually incorrect, and not likely to be useful
to the OP.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 27 '07 #7
"_mario.lat " <no**@libero.it wrote in message
news:pa******** *************** *****@libero.it ...
what does it means "the function is not thread-safe"?
It means that the function is likely to behave incorrectly if you call it
from multiple <OT>threads</OT>. The canonical example is strtok().

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

May 28 '07 #8
osmium wrote:
Since about 70% of the threads on this and c.l.c++
groups are about off-topicness, do not top post, snip signatures, do
not snip attributions, signatures must be introduced by --, no more
than four lines on a signature, read the FAQ, this is off topic, and
general net etiquette

You're a liar.

Brian
May 28 '07 #9
Stephen Sprunk wrote:
"_mario.lat " <no**@libero.it wrote in message
>what does it means "the function is not thread-safe"?

It means that the function is likely to behave incorrectly if you
call it from multiple <OT>threads</OT>. The canonical example is
strtok().
And threads are not processes. Threads share data space, which is
why strtok can go BOOM. However tknsplit (nee toksplit) is clean.
See recent posts here (last 4 or 5 days only).

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 28 '07 #10

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

Similar topics

2
1704
by: Tee | last post by:
Hi, Can we use thread.start on a function that has return value? I have a function that will take sometimes to run and it will return a string value, and I want to use thread.start to call this function and get the string, is this possible? Thanks,
6
2645
by: Christian Buckl | last post by:
Hi, I try to implement my own thread class based on POSIX threads. I want my class to manage everything (creation of threads, exception handling...). This includes also some functions that need to be called within the threads context (like setting the cancelability state and type). That´s why I am using a function that initializes the thread and then calls the original thread function. The problem is, that I can't manage to implement the...
5
3004
by: Luke Dalessandro | last post by:
Code: Thread -> U -> T public class Thread { protected: thread_t _tid; virtual void foo() = 0; public: // Static entry function for the internal thread
3
2121
by: kiplring | last post by:
Suppose a function which has Sleep() method in it. And I want to recycle it. I made two buttons which call "Resume()" and "Suspend()". But It doesn't work. The state of thread "t" will be "WaitSleepJoin" when it runs because the function it calls - "GenerateEvents()" has "Sleep()" function. Can I solve this problem with Thread? I don't want add nasty boll flags on it.
10
2012
by: Alfonso Morra | last post by:
Hi, I need help witht he sleep function as follows. I need to be write som code to do the ff: 1. creates a new thread 2. (in the new thread), Sleep for x milliseconds 3. (in the new thread), After time elapsed, call a function via a callback 4. ability to kill the spawned thread.
1
2303
by: Sivaraman.S | last post by:
Hi, I have thread declared in this way. Dim t As New Thread(AddressOf ThreadProc). Here ThreadProc is a function with two parameters. But i am not able to use function name with addressof, It accepts only if it is 'Sub' and not 'function'. Can anyone help me with some good example, to use thread for functions with some parameters. thanking u,
3
2032
by: Sam Learner | last post by:
Hello everyone, I am developping an application, I create a thread for the application because it is about to download a large file, and wanted it to do it inside of a thread... Now, the function I need the thread to call has a parameter... How do I call a function with the addressof(..) with a parameter value? for example: public function processData(byval data as arraylist) as boolean.... ....
10
15183
by: ChrisB | last post by:
Coming from a C/C++ background, how would I pass a function pointer to a function? I want to write a function that handles certain thread spawning. Here's what I'm trying to invision: function( thesub as <functionptr?> ) dim t as new system.threading.thread( _ new system.threading.threadstart( Addressof thesub )) .... How can I get something like that going in VB.Net?
2
2118
by: Franck | last post by:
I am looking for a way to pass a function as parameter, NOT A DELEGATE. what i am trying to do is a worker process as for example of what i want to do : public static void StartWorking(FUNCTION MyFunction) { //thread object private Thread tWorkingProcess;
1
1575
Airslash
by: Airslash | last post by:
Touchy subject I know, but I'm currently trying some stuff to understand Threads better in C++. I've read the Windows API documentation regarding Threads, and want to build a Thread class that can run any kind of function as a seperate thread by utilising function pointers. This is the code I currently have so far: header file //--------------------------------------------------------------------------- #ifndef ThreadH #define ThreadH
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.