Learning in threshold networks