Implement lock statement over generic type parameter