First of all consider two lines:
- The lesson had ended by the time I arrived.
- The lesson had ended at the time I arrived.
Now I wanted to ask you, among the above two lines which one is correct and define reason to be the right and wrong. Another thing is the difference between "At the time" and "By the time" and in what situation we will use which one
If I made any mistakes in the question then please mention it in the comment.