473,786 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about threads?

I have a question about threads:
In the TCPClient help page I find the following explanation

"Thread Safety
Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations. Any instance members are not
guaranteed to be thread safe."

What does it mean, I need an example of something that is not safe.

Tia
Nov 21 '05 #1
2 916
By members, it means methods. i.e. if you intend to call the same method of
the same *object* from two threads, you need to provide synchronisation . If
you only intend to call two static methods of the same *type* from different
threads, then you probably won't need to provide synchronisation as all the
data will be largley stack based.

"Fekkai" wrote:
I have a question about threads:
In the TCPClient help page I find the following explanation

"Thread Safety
Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations. Any instance members are not
guaranteed to be thread safe."

What does it mean, I need an example of something that is not safe.

Tia

Nov 21 '05 #2
I'm not sure I agree with the last statement. Static methods can only access
static data members (right?), and the latter can not be implemented on a stack
because then they wouldn't be shared.
So, it must be that the class implementor knows that the static data members
are accessed using a monitor or some other mechanism that ensures thread
safety, no?

"Bonj" wrote:
By members, it means methods. i.e. if you intend to call the same method of
the same *object* from two threads, you need to provide synchronisation . If
you only intend to call two static methods of the same *type* from different
threads, then you probably won't need to provide synchronisation as all the
data will be largley stack based.

"Fekkai" wrote:
I have a question about threads:
In the TCPClient help page I find the following explanation

"Thread Safety
Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations. Any instance members are not
guaranteed to be thread safe."

What does it mean, I need an example of something that is not safe.

Tia

Nov 21 '05 #3

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

Similar topics

1
1626
by: Randy Geyer | last post by:
I have an NT/W2K service that spawns 3 worker threads that each do different things. For example, one monitors an email mailbox for incoming items and puts them in a queue for processing by a 2nd thread. The 3rd thread polls a database for updates and performs different processing. The actual implementation is more complicated than this, but that's the basic architecture. My question is this: How do I gracefully shut down the service...
2
1468
by: grahamo | last post by:
Hi, I realise that c++ knows nothing about threads however my question is related to an (excellent) article I was reading about threads and C++. For all intents and purposes we can forget the sample at hand is concerned about threads, it could be related to widgets for the purpose of this question (that's so I don't get flamed and told to go to comp.programming.threads :)
3
1362
by: jackowilkinson | last post by:
assuming code: int i=0;//global variable //process 1 //process 2 int num=0; int num=0; while(i<5){ while(i<5){ num=num+1; num=num+1; i=i+1; i=i+1; } }
2
1506
by: Leon Mergen | last post by:
Hello, Ok, I'm having a problem when trying to make the classes I make a bit more generic. Consider this: I have one class, ClassA. This defines some interface methods, and ClassB inherits from it, and adds some of its own variables. Now, I'm making a library, which accepts ClassA. Now the problem is, this library also creates a lot of threads. I want
11
4270
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
5
1703
by: Peter Kirk | last post by:
Hi, I see in the ThreadPool documentation that the pool has a default limit of 25 threads. Is it correctly understood that this limit is for my entire application? So if I have several worker-threads each using "ThreadPool.QueueUserWorkItem" then the limit is spread over all my worker-threads - so if "worker-thread-1" currently has 20 calls in progress then there are only 5 thread-pool threads available for "worker-thread-2" ?
6
6240
by: Padhu Vinirs | last post by:
JDK 1.4 on WinXP. I have 2 threads started from the main thread. I would like to print some status of the child threads from the main thread periodically. But I dont see the main thread to print out anything when the child threads are running. The child threads do sleep after some work. Instead should I make the child threads wait() and make the main thread notifyAll() after printing ? public class MainThread { WorkerThread t1, t2;...
27
1741
by: Ritesh Raj Sarraf | last post by:
Hi, I have some basic doubts about thread. I have a list which has items in it which need to be downloaded from the internet. Let's say list is: list_items which has 100 items in it.
3
1997
by: Chris Roth | last post by:
I'm using VS.net 7.1 on Windows XP. I have a class that hold a container of doubles. One function (foo) for the class calls a sub-function (bar) for each of the doubles. I'd like to multithread foo so that the bar sub-functions can run on multiple threads. I'd like to imlpement this with _beginthreadex as I'm using std::vector. Please provide some working code around the following details: #include <windows.h // for HANDLE...
19
1807
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. Threading is a new concept for me to implement. Here is my problem. I have a system that receives xml files and records their file locations in a database. I can potentially receive thousands,
0
10163
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
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
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
6744
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
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
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
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.