when should I use 'lock' in multi-thread programing?
===

when should I use 'lock' in multi-thread programing? Just lock the area which each thread will modify or lock the area which each thread can access even it will not be modified ?

    struct share_data {
        /* share data */
        thread_id;
    }

    thread 1 will exceute main() function:
       Initial share data. /* need lock */
   
       join all thread(share_data.thread_id, &status)   /* access share data thread_id, lock or not? */
       exit.

    other threads will:
       access share_data, /* lock or not? */
       modify share_data, /* lock */
       exit.
