HPlogo Debugging threads with HP Wilde Beest Debugger

Best Practices in Thread programming

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

The following are some of the best practices specific to Thread-programming:

  • Ensure your program locks small segments or specific fields of a program segment to increase concurrency in execution.

  • Ensure that your locks always obtain synchronization control in an order that does not cause race condition.

  • Minimize locking instances so you can reduce the overhead that might result from frequent synchronization efforts.

  • Minimize critical sections that might result in longer waits for other threads.

  • Reduce the number of nested function calls so you avoid errors resulting from stack overflow.

  • Consider writing a recursive function in an iterative form, as sometimes an iterative function demonstrates greater resource efficiency than a recursive function.

  • Minimize the size and number of the stack local variables to reduce the stack usage of a thread.

  • Allocate large data items dynamically in a heap than in arrays to ensure that stack utilization does not exceed the allocated or default percentage.

© 2008 Hewlett-Packard Development Company, L.P.