Click to See Complete Forum and Search --> : thread safety


fleck
August 22nd, 2005, 07:05 AM
Hi,
I' ve to make a software module thread safe.
I know how to realize that and what' re the main topics of thread safety.
But I don' t know how thread safety can be tested. I read about a test for web servers. These apps' re tested with a stress test. That doesn' t work for my module. I searched the web but didn' t find a solution that satisfies me. I think that thread safety errors don' t occur reproduceable and so they' re hard to test and find.
Any ideas?

Thanks,
Alex.

darwen
August 25th, 2005, 06:22 AM
The way that I test thread safety is to

(1) Produce an operation which uses every method on the multithreaded classes.
(2) Create 200 (or as many as deemed necessary) threads in an application each running this operation.
(3) Run the app for a week.

You should have some sort of UI indicator for each of the threads so you can monitor them.

You're looking for things like thread starvation too - i.e. a thread infinitely blocking on a piece of code.

Darwen.

proghelper
August 25th, 2005, 09:11 AM
Watch out for the shared resources. That is the biggest headache in thread safety.

As an example, if you have a data structure that you could read and write to in parallel, then in order to ensure thread safety, you have to us locking and unlocking.

----------------------

Programming ( Assignment / Project ) Help (http://www.programminghelp4u.com/)