Job change with H1B before 1st October

I am currently on F1 visa and I have job offers from two companies, A and B. Company A is going to apply for my H1B before 30th June. My opt is going to start on 15th August. Is there any way I can join company B without getting H1B from company A void? Do I have to work for company A till 1st October even if they apply for H1B with consular processing? How will the visa stamping work since I have never joined company A who applied for my H1B visa? Thank you.