Example #1
0
int main(int argc, char* argv[])
{
    RandomDelay::Initialize();
    
    printf("is_lock_free: %s\n", flag.is_lock_free() ? "true" : "false");
    
    for (;;) {
        sharedValue = 0;
        thread thread2(Thread2Func);
        IncrementSharedValue10000000Times(randomDelay1);
        thread2.join();
        printf("sharedValue=%d\n", sharedValue);
    }
    
    return 0;
}
Example #2
0
int main(int argc, char* argv[]) {

    use_atomic = (argc > 1) ? true : false ;

    printf("is_lock_free: %s. is using atomic? %s \n",
        flag.is_lock_free() ? "true" : "false",
        use_atomic ? "true" : "false"
        );

    for (;;) {
        sharedValue = 0;
        thread thread2(Thread2Func);
        IncrementSharedValue10000000Times(randomDelay1);
        thread2.join();
        printf("sharedValue=%lu\n", sharedValue);
    }

    return 0;
}