![]() |
| | #1 |
| Registered User Join Date: Oct 2006
Posts: 58
| Multi Threading How do I create a multi threading program? |
| beon is offline | |
| | #2 |
| Fear the Reaper... Join Date: Aug 2005 Location: Toronto, Ontario, Canada
Posts: 625
| It depends on your platform. If you're on Linux, man the fork command.
__________________ Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction |
| Happy_Reaper is offline | |
| | #3 |
| Registered User Join Date: Nov 2006
Posts: 176
| search around for pthread examples. fork() just creates a child process |
| sl4nted is offline | |
| | #4 |
| Registered User Join Date: Oct 2006
Posts: 58
| Hi Happy_Reaper, let say I'm using visual C++ v6, how would you suggest? I had never tried multi thread before. so basically I doesn't know how to. Is there anything I can look out for? |
| beon is offline | |
| | #5 |
| Registered User Join Date: Nov 2006
Posts: 176
| I think windows has pthreads library, maybe not try this Code: #include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void *hello(void *arg) {
printf("hello world\n");
}
int main() {
pthread_t thread_block;
void *status;
if (pthread_create(&thread_block, NULL, hello, NULL) != 0) {
perror("pthread_create");
exit(1);
}
if (pthread_join(thread_block, &status) != 0) {
perror("pthread_join");
exit(1);
}
return 0;
}
|
| sl4nted is offline | |
| | #6 |
| Registered User Join Date: Oct 2006
Posts: 58
| Thanks sl4nted, To be true my program are in c, even though I use a visual c++ to compile. I'm kind of a green horn so I would really like to try everything. I'll try the example that are listed .. thanks alot. =) |
| beon is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| overlapped I/O and multi threading | krishnampkkm | C++ Programming | 2 | 06-22-2009 03:27 PM |
| Looking for light cross platform Threading library | umen242 | C++ Programming | 7 | 03-28-2008 04:23 PM |
| Singleton C++ Class - How to avoid mem leak in multi threading | molus | C++ Programming | 6 | 06-02-2006 08:32 AM |
| starting to learn multi threading | hanhao | C++ Programming | 2 | 06-09-2004 01:44 PM |
| Multi Threading | IceBall | C Programming | 7 | 07-13-2003 03:01 PM |