Under the present invention, program code is examined (statically or
dynamically) for characteristics indicative of a potential to generate
multiple threads. If none are found, single threaded optimization(s) such
as desynchronization, optimization of globals, etc., can be implemented.
In addition, if the program code is later revealed to have the potential
to generate multiple threads, the single threaded optimization(s) can be
corrected to avoid incorrect execution.