Microsoft Interview Question

How does contex switch works? where the program variables are held? how one can share same variable of different threads?