Pattern-based Verification for Multithreaded Programs