Applying for multiple lecturer posts in the UK There are multiple lecturer openings in the UK that are very relevant to my work, say posts A and B. I prefer B over A, but B's application deadline is a about 2 months after A's. 

If I apply for both posts, there is a chance I might be accepted for A while I am still waiting for a response from B. In that case, how should I react and what should I do if I get a positive response from B after I have accepted the offer from A? 

My question is particular to the UK. In Germany, for example, I know that people openly apply for multiple positions and leverage this for negotiations. But I am not sure if the process is the same in the UK.
how should I react and what should I do if I get a positive response from B after I have accepted the offer from A


This should not happen except in very rare circumstances. The typical UK hiring timeline is the job is announced with a known interview date and an offer will be made within days (sometimes hours) of the interview. They would then expect you to verbally accept the offer within days and then ideally present you with a contract a day or so after that.

The conventional wisdom is that after getting the contract, you should withdraw your other applications. If you verbally commit to A, but A cannot generate a contract in a timely manner, then most people (but not necessarily the people at A) will understand if you accept another offer. I am not a huge believer in the conventional wisdom. A good job offer can be your job for the rest of your life and to turn down your dream job in your dream department at your dream university in your dream city with great resources and salary and a position for your partner for a job you do not want to do with crappy resources and salary in city you hate, in my opinion is not reasonable. To screw over a department because someone else offered you a step higher on the salary scale also does not seem reasonable. In other words, you need to use your judgment to decide what to do.