Hello friends have a doubt in threaded application.
    class sample
    {
        static volatile bool _shutdownThreads;
        static readonly object _lockerObject = new object();
    main()
    {    
       create thread for samplemethod()
       lock(_lockerObject)
       {
           _shutdownThreads = true;
       }
    }
    samplemethod()
    {
       while(true)
       {
          lock(_lockerObject)
          {
             if(_shutdownThreads) break;
          }
        }
    }
    }
(1)ok i guess you might have understood what i am trying to accomplish. I need to have a safe way to use the _shutdownThreads variable. is this the right approach?
(2)if i lock a block of code all the variables inside the block gets locked too? i mean even other threads(for example main) cant access the variable. am i right?