glutz
glutz

Reputation: 1959

Is it possible to programmatically freeze threads on Windows?

In visual studio, for example, one can freeze/thaw any thread at any time. Is is possible to do this programmatically in order to create a stress test of sorts for threaded code? If any thread could be frozen randomly for a random amount of time, it would really exercise the synchronization logic.

Upvotes: 4

Views: 874

Answers (2)

Rick
Rick

Reputation: 3353

You can do this with SuspendThread & ResumeThread, you'll need the thread handle which you get by calling OpenThread. The thread functions page on msdn is a good resource for this sort of thing.

Upvotes: 3

Mayank
Mayank

Reputation: 8852

you can create a Thread which randomly picks Thread's from ThreadPool and put them to sleep for random amount of time. If that's what you are after.

Upvotes: 1

Related Questions