Torque wrench working principle

I would like to know the working principle of torque wrench. For analyzing a design of bolted joint (specifically to calculate the thread strip margin for a stud)a bolt which is torqued using a torque gun, when does the wrench clicks ?

Does the wrench click when

1. the stud/bolt will encounter the end of threads into threaded insert (female part) and the further motion is opposed (opposing torque exceeds the calibrated wrench torque after the end of threads) ?

OR

2. after the specific number of threads produces enough amount of counter torque to oppose the applied torque by wrench ?

The wrench will click once the torque limit is reached. Essentially what you are specifying by the torque is the amount of pinch (pretension) the bolt will have. The threads are converting the torque into a linear force along the axis of the bolt. This value varies by many factors for each individual bolt type. The idea is that the number of threads isn't considered. Since the thread (nut) should be designed where the threads do not fail first but actually the bolt shank.