due palle con i thread....
Von: mitic (mit@libero.it) [Profil]
Datum: 03.03.2008 12:48
Message-ID: <fqgoj8$1bhn$1@newsreader2.mclink.it>
Newsgroup: it.comp.os.linux.development
Datum: 03.03.2008 12:48
Message-ID: <fqgoj8$1bhn$1@newsreader2.mclink.it>
Newsgroup: it.comp.os.linux.development
non riesco a creare un semplice thread in kdevelop sotto linux (kubuntu)
allora, ho fatto questo semplice esempio che non viene compilato per un
errore:
undefined reference to 'pthread_create
me lo da sulla riga if (( err=pthread_create(&tid, NULL, &myfunz, NULL)) !
0 )
#include <pthread.h>
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
static int x; /* la var condivisa */
static void* myfunz (void* arg){
while (1) {
printf("Secondo thread: x=%d\n",++x);
sleep(1);
}
}
int main (void) {
pthread_t tid;
int err;
if (( err=pthread_create(&tid, NULL, &myfunz, NULL)) != 0 )
perror("fine thread");
else { /* secondo thread creato */
while (1) {
printf("Primo thread: x=%d\n",++x);
sleep(1);
}
}
}
porca miseria che palle....
[ Auf dieses Posting antworten ]Antworten
- mitic (03.03.2008 13:05)
- ilSimo (03.03.2008 13:54)
- mitic (03.03.2008 14:50)
- Alessandro Pellizzari (03.03.2008 15:22)
- mitic (03.03.2008 16:30)
- ilSimo (03.03.2008 15:28)
- Ottavio Campana (04.03.2008 09:45)
