You need a java Mutex for that, there is enough information on internet for that subject available, for example this.
After that the commit is done (within mutex code) use session.endTransaction (see community) to save the number
Hi Nags,
If you're specifically looking to have a sequence for quotenumbers, probably a good idea to create a QuoteNumberSequence entity just for this, make it have an autonumber field, and use this autonumber field as part of determining the quote number. Everytime you need a new quote number, you just create a new QuoteNumberSequence record and read it's autonumber field.
The platform will guarantee these autonumbers to be unique and sequential, even when running on multiple nodes.