Friday, September 30, 2005 |
|
|
This session by Joe Duffy had more practical advice about programming with concurrency. Some highlights:
- It is important to maintain invariants (“assumed conditions in your code”), even in the face of exceptions.
- Asynchronous exceptions like thread aborts can happen almost anywhere, which can make invariant maintenance difficult, but .NET prevents them from being thrown from certain sensitive areas, such as catch/finally blocks, static constructors, and native code.
- Generally speaking, when you write a class, you should make any static state thread-safe, but require your client to lock access to your class instances, since you can’t predict their concurrency needs.
- Always protect shared memory with locks. In .NET, locks do more than prevent concurrent access; they also guard the code against hardware instruction reordering, etc.
- In the future, parallel programming will be the only way to leverage the increasing speed of computers, as the speed of a single CPU is nearing its physical maximum.
|
9/30/2005 12:37:11 PM (Pacific Standard Time, UTC-08:00) | | Development
|
|
|
|
|
|
|
| Archive |
| March, 2008 (1) |
| January, 2008 (1) |
| September, 2007 (1) |
| July, 2007 (1) |
| June, 2007 (3) |
| May, 2007 (2) |
| January, 2007 (2) |
| December, 2006 (1) |
| November, 2006 (2) |
| August, 2006 (6) |
| July, 2006 (3) |
| May, 2006 (4) |
| April, 2006 (2) |
| March, 2006 (1) |
| February, 2006 (1) |
| January, 2006 (1) |
| December, 2005 (2) |
| November, 2005 (5) |
| October, 2005 (11) |
| September, 2005 (7) |
| August, 2005 (1) |
| July, 2005 (2) |
| June, 2005 (2) |
| April, 2005 (5) |
| March, 2005 (11) |
| February, 2005 (6) |
| January, 2005 (2) |
| December, 2004 (1) |
| November, 2004 (1) |
| October, 2004 (3) |
| September, 2004 (1) |
| August, 2004 (5) |
| July, 2004 (10) |
| June, 2004 (3) |
| May, 2004 (5) |
| April, 2004 (3) |
| March, 2004 (10) |
| February, 2004 (10) |
| January, 2004 (15) |
| December, 2003 (1) |
| November, 2003 (2) |
| October, 2003 (13) |
| September, 2003 (20) |
| August, 2003 (24) |
|
|
|
|