Skip to main content

Context Switching

Posted by doj on April 20, 2006 at 1:42 PM PDT

OK, so the human brain is supposed to be designed to multitask. That means through the course of a single day, we might have to switch between literally thousands of individuals tasks. It seems that although we're all designed to do this, some of us do this better than others. Maybe some of us have better schedulers than others?

Take my lovely wife Linda. She has possibly the best scheduler I know! Somehow she can juggle many "threads": type an e-mail, talk on the phone, carry on two side-conversations and perhaps feed the cat - all simultaneously. She does this almost effortlessly! Now let's look at case number two: me. I can be immersed in some code, replying to an e-mail and perhaps having a side conversation. BUT, there's a significant observable time delay for me switching focus from one activity to another. I never noticed this until recently... perhaps my scheduler is getting old ;-)

This got me to wondering... how cognisant are Java developers of thinking about solutions in terms of multi-threaded approaches. If we can successfully make our way through the day by handling so many things at once, perhaps that's how we should conceptualize application development?

Fortunately for us, with Java's core support for multi-threaded development, and some of the more recent advances in concurrent programming support, we're certainly well placed to work this way. The JVM almost certainly seems to be able to juggle threads much better than I can on modern Operating Systems! Certainly for my next project, I'm going to think about how Linda would tackle the problem, and perhaps design my application in the way she'd do that.

Related Topics >>