Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pthread.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #define NUM_THREADS 2
- char *num = "0123456789";
- char *alpha = "abcdefghijklmnopqrstuvwxyz";
- void *PrintSeq(void *inSequence)
- {
- char *i = (char*)inSequence;
- while(1)
- {
- if (*i == 0) i = (char*)inSequence;
- printf("%c", *i);
- printf("TEST");
- i++;
- sleep(1);
- }
- pthread_exit(NULL);
- }
- int main (int argc, char *argv[])
- {
- printf("PRINT?");
- pthread_t threads[NUM_THREADS];
- int rc;
- rc = pthread_create(&threads[0], NULL, PrintSeq, (void*)num);
- if (rc){
- printf("ERROR: Failed to create threads");
- exit(-1);
- }
- rc = pthread_create(&threads[1], NULL, PrintSeq, (void*)alpha);
- if (rc){
- printf("ERROR: Failed to create threads");
- exit(-1);
- }
- pthread_exit(NULL);
- }
Add Comment
Please, Sign In to add comment