Devices and methods for treating or repairing a heart are disclosed. The device includes at least one anchor configured to engage tissue of a heart and a thread or other elongate member adapted to be coupled to the anchor and secured to heart tissue. The anchor may be attached to papillary muscle tissue and an elongate member may be attached to a valve leaflet for creating artificial chordae tendinae, thereby treating mitral valve prolapse. In another application, multiple anchors may be deployed within a ventricle and the threads pulled together for reducing dilation of a ventricle. A locking mechanism is provided for capturing and locking the threads together, thereby maintaining the ventricle in the reshaped condition.