nntp2http.com
Posting
Suche
Optionen
Hilfe & Kontakt

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
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