1. A method of detecting a datarace between memory accesses within a program, said method comprising: determining, as executed by a processor on a computer, whether a datarace exists between a first access event in a first statement and a second access event in a second statement; if it is determined that a datarace exists between the first and second statements, adding said first and second statements to a list; determining whether a third statement is more weakly protected than at least one of the first statement and the second statement, said determining whether said third statement is more weakly protected comprises determining whether the third statement has a lockset which is a subset of locksets of the corresponding first and second statements; and if the third statement is determined to be more weakly protected than at least one of the first statement and the second statement, replacing the corresponding at least one of said first and second statements in the list with the third statement.