#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

struct key_type {
    int value;
    key_type() : value(0) {
        sleep (1);
        pthread_yield();
        value = 42;
    }
};  


void * thread1(void*) {
    static key_type local_key;
    printf("thread has key %d\n", local_key.value);
    return NULL;
}   

int main()
{
    pthread_t t[2];
    pthread_create(&t[0], NULL, thread1, NULL);
    pthread_create(&t[1], NULL, thread1, NULL);
    pthread_join(t[0], NULL);
    pthread_join(t[1], NULL);
}   