• Threads in abundance can give rise to thread switching and thread management
penalties. This is something that needs to be watched for at the design time.

• The logic for mutexlconditions needs to be designed carefully. A small mistake there can cause mutexl conditions deadlocks or starvations.

• Writing 'Thread Safe' code is extremely important. It basically boils down to understanding what is shared and what's not shared. Following are the things that are shared across threads (and hence need managed access):

• Global data

• Static variables.

•Heap/dynamically allocated memory if the address gets communicated across threads.

•Any system resource (such as file descriptors,
sockets etc.)

Name:  Some pitfalls.jpg
Views: 25
Size:  40.7 KB

Things that are not shared

•Local and stack variables.

•Thread specific data.

•Consistent system state and proper recovery in case of thread getting killed.