Modular Verification of Multithreaded Programs