Get up and walk around when you feel tired.
Staying through a long lecture can be tiring and frustrating. When you feel tired get up and move about, if the lecturer should ask why you are roaming about, explain to him/her that you need to stretch your legs.
The lecturer should understand that you need to do this to be comfortable to continue the lecture.
Make little movement while sitting in class.
Little movements like stretching in your chair or tapping your feet on the floor quietly can help in keeping your body active and prevent you from falling asleep. Do this quietly in order not to distract other students.