Dynamic validation of contracts in concurrent code