What you describe happens all the time with almost every function, and it isn't a problem.
Perhaps you mean the alternative of where T2 tries to call X(), while T1 is already in X().
That's re-entrancy, and is a far more interesting problem.
And no, you can't just "test" to see if a function is re-entrant by calling it a bunch of times from two threads, and seeing what happens.
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Offline 7,164 posts
since Dec 2005