Runtime verification of multithreaded systems, that is, the process of finding errors in multithreaded systems as they execute, is the theme of this paper. The major goal of the work in this paper is to present an automatic code instrumentation technique, based on multithreaded vector clocks, for generating the causal partial order on relevant state update events from a running multithreaded program. By means of several examples, it is shown how this technique can be used in a formal testing environment, not only to detect, but especially to predict safety errors in multithreaded programs. The prediction process consists of rigorously analyzing other potential executions that are consistent with the causal partial order: some of these can be erroneous despite the fact that the particular observed execution was successful. The proposed technique has been implemented as part of a Java program analysis tool, called Java MultiPathExplorer and abbreviated JMPAX. A bytecode instrumentatio...