473,898 Members | 4,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What are the threading options in C++

Hi all,

I'm just wondering what's the best option for threading in C++? I've
used pthreads and forking in C (the latter is not appropriate for my
situation now). All I want to do is run a function in a new thread, it's
a simple task, no interaction with other threads etc. so I don't have to
worry about deadlock, starvation and so on.

Thanks,

Lionel.
Jul 23 '05 #1
4 1268
Boost.Threads is a good threading library for C++:

http://www.boost.org/doc/html/threads.html

Lionel van den Berg wrote:
Hi all,

I'm just wondering what's the best option for threading in C++? I've
used pthreads and forking in C (the latter is not appropriate for my
situation now). All I want to do is run a function in a new thread, it's
a simple task, no interaction with other threads etc. so I don't have to
worry about deadlock, starvation and so on.

Thanks,

Lionel.

Jul 23 '05 #2
Lionel van den Berg <ch***********@ hotmail.com> wrote in news:d086lp$ebb $1
@bunyip2.cc.uq. edu.au:
Hi all,

I'm just wondering what's the best option for threading in C++? I've
used pthreads and forking in C (the latter is not appropriate for my
situation now). All I want to do is run a function in a new thread, it's
a simple task, no interaction with other threads etc. so I don't have to
worry about deadlock, starvation and so on.


Threading is off-topic in comp.lang.c++. The Standard makes no mention of
threading. You're in OS-specific land and should ask in an OS-specific
newsgroup. Having said that, you may wish to go look in Boost. As I
recall, they have a threading class... (http://www.boost.org)
Jul 23 '05 #3
Andre Kostur wrote:
Lionel van den Berg <ch***********@ hotmail.com> wrote in news:d086lp$ebb $1
@bunyip2.cc.uq. edu.au:

Hi all,

I'm just wondering what's the best option for threading in C++? I've
used pthreads and forking in C (the latter is not appropriate for my
situation now). All I want to do is run a function in a new thread, it's
a simple task, no interaction with other threads etc. so I don't have to
worry about deadlock, starvation and so on.

Threading is off-topic in comp.lang.c++. The Standard makes no mention of
threading.


My apologies.
You're in OS-specific land and should ask in an OS-specific
newsgroup. Having said that, you may wish to go look in Boost. As I
recall, they have a threading class... (http://www.boost.org)


Thanks.

Lionel.
Jul 23 '05 #4
Andre Kostur wrote:
Lionel van den Berg <ch***********@ hotmail.com> wrote in news:d086lp$ebb $1
@bunyip2.cc.uq. edu.au:

Hi all,

I'm just wondering what's the best option for threading in C++? I've
used pthreads and forking in C (the latter is not appropriate for my
situation now). All I want to do is run a function in a new thread, it's
a simple task, no interaction with other threads etc. so I don't have to
worry about deadlock, starvation and so on.

Threading is off-topic in comp.lang.c++. The Standard makes no mention of
threading. You're in OS-specific land and should ask in an OS-specific
newsgroup. Having said that, you may wish to go look in Boost. As I
recall, they have a threading class... (http://www.boost.org)


Actually it's not /that/ off-topic, since IIRC threading and concurrency
is planned to be supported by C++0x.

--
Matthias Kaeppler
Jul 23 '05 #5

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

Similar topics

17
2455
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next = gen.next() finally:
3
539
by: Suhail Salman | last post by:
Dear All, i got the following error message in an applications that opens 13 threads and all of them calling a stored procedure which retreieves data from SQLServer and fills them to a table the error appears at the following statment sqlda.Fill(dtMessages); During an infinit loopp
8
13499
by: Yatharth | last post by:
Hi, I m new to threading and i have successfully runed threading but i could display value on my web page ,but its working in code behind when i see it through debugger,plzzzzzzz help me here is the code below: i just wana display the simple array value stored in my array variable in my textbox thats it.
3
1156
by: Eric Sabine | last post by:
OK, I have an app that when it loads, it calls a sub which loads a dataset from a web service. I spin the call on another thread so the user doesn't get an unresponsive screen. The problem ensues when the web service can't be contacted (which is OK). I throw up a messagebox to the user and an opendialog control, but since this is happening on another thread, the user can still do activity in the main form. I suppose this breaks a...
17
1460
by: One Handed Man \( OHM - Terry Burns \) | last post by:
Assumes a Form with a Panel on it., Does the Mutex have to be within the address of a thread start address ? Cheers - OHM '----------- *************** ---------------- Private endProgram As Boolean = False Dim image1 As Image = Image.FromFile("..\Images\gun.bmp")
1
1090
by: mburghdorf | last post by:
I am currently working on a vb.net program that interacts with autocad. The thread processes a building that was created within the program and comes up with a price. I then after the job has been priced give the user an option to display a report that they would be interested in. One of the options interacts with autocad and errors out. If I disable threading it then works perfectly fine. I am not sure why this happens or why threading...
3
1389
by: JMax | last post by:
Hello! I have a C# ASPX page that displays a large amount of information. The software loops through 500 lines of code (and some of the 500 lines are looped multiple times, in a loop). Naturally, it takes approximately 7 seconds for the Page_Load event to fire (where I have all of my code).
2
1905
by: VMI | last post by:
I'm filling up a gridview and the underlying datatable has about 30,000 records, so it takes some time before I can see the page again with the records on the gridview. Is there any type of threading (or anything else) that I can use so that I can display some message (i.e. "Grid loading...") or any way so that I can start viewing the records? Thanks.
167
8413
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++ doesn't have such functionality, say in its STL. This absence of a thread/object relationship in...
0
11265
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10488
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
9662
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
8036
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
7191
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
5882
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6079
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4712
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
3
3309
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.