A method and apparatus are provided for detecting data races that overcome
the limitations of the prior art. In some embodiments, this is
accomplished by detecting a first access to an object, determining
whether the first access is associated with a suspicious pattern,
automatically refining a pattern detection granularity from the object to
a memory location within the object if a determination is made that the
first access is associated with the suspicious pattern, and reporting the
data race if a second access associated with the suspicious pattern
occurs at the memory location after the pattern detection granularity is
refined.