What is the difference between a process and a thread, and how does the operating system handle context switching between them?