That should work...
Well, depends: Is there exactly ONE even thread, and exactly ONE odd thread? => Or are there several of at least one of them.
If there are several, then it is a problem.
If there are several then you need (iirc)
InterlockedCompareExchange(FlagEven, 1, 0)
Set it to 1, but only if it really still is 0. (Because, otherwise 2 threads can set it to 1.)
And use the result of that for the "if" condition
If there is ONLY ONE thread of each then... Well, afaik technically you need Read/Write barriers in some cases. But it may work without. Though, I would put a "WriteBarrier;" in front of the assignments setting it to 2 or 0 (before the "end" of the "if"'s begin/end block).
Interlocked, does include the needed barriers.
--- EDIT:
Well actually, if you have ONLY ONE of each thread. You may need ReadWriteBarrier after entering each if block.