# Thread-Specific Data: Example - Main.

###

    #include <pthread.h>
    #include <stdlib.h>

    pthread_key_t    key1, key2;
    void destruct(void *value), start_func(int thread_num);

    main()
    {
        int        ret_val;
        pthread_t    tid1;
        ret_val = pthread_key_create(&key1, (void *) NULL);
        ret_val = pthread_key_create(&key2, destruct);
        ret_val = pthread_create(&tid1, (pthread_attr_t *)NULL,
                (void *(*)(void *))start_func,(void *) 1);
        start_func(0);
        ret_val = pthread_join(tid1, (void **)NULL);
        ret_val = pthread_key_delete(key1);
        ret_val = pthread_key_delete(key2);
    }

Previous slide | Next slide | Back to first slide | View graphic version