Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I start to use multithread programming?

I am a beginner on Stack Overflow. I am working on a Unix platform in C/C++. Knowing basic programming in these regards how could I start with multithreading?

Multithreading seems to be very interesting and I want to grow my knowledge in this regard.

How could I get started with multithreading and what are the best techniques/books/ebooks/articles available to grab the concepts as early as possible?

like image 745
Vijay Avatar asked Nov 10 '09 10:11

Vijay


People also ask

How do I run a multithreading program in C++?

To start a thread we simply need to create a new thread object and pass the executing code to be called (i.e, a callable object) into the constructor of the object. Once the object is created a new thread is launched which will execute the code specified in callable. After defining callable, pass it to the constructor.

How do I start multithreading in Java?

In order to create a Thread, first we need to create an Instance of RunnableWorker which implements the Runnable Interface. The above code creates a Runnable Instance r. Then it create 3 threads t1, t2 and t3 and passes r as the argument to the 3 threads. Then the start() function is used to start all the 3 threads.

How do I run a thread program?

To execute the c file, we have to use the -pthread or -lpthread in the command line while compiling the file. Syntax: int pthread_create(pthread_t * thread, const pthread_attr_t * attr, void * (*start_routine)(void *), void *arg);


1 Answers

Something else to try: http://www.threadingbuildingblocks.org

like image 175
mr grumpy Avatar answered Sep 23 '22 21:09

mr grumpy