Возможно, стоит пояснить разницу между синхронизацией из thread/process-safe и синхронизацией с помощью Lock🤔
Наша задача — заставить разные процессы и потоки обращаться к базе данных (или любым другим ресурсам) последовательно. Чтобы не случилось так называемого race condition, то есть состояние гонки. Это когда разные потоки или процессы пытаются одновременно что-то сделать с одним и тем же ресурсом.
В этом случае нам нужна какая-то логика ограничения. Пока один процесс не завершил своё действие, другие не могут получить доступ к ресурсу.
Так вот, thread-safe и process-safe означает что отдельно взятые операции записи в БД гарантированно будут последовательны. Запросы из разных процессов или потоков выстроятся в очередь и не будут мешать друг другу. Лучше всего когда этот блок реализован на уровне БД в виде атомарных операций или ещё как-то.
Но зачем нам тогда еще дополнительный Lock?
Этот способ синхронизации используется когда процесс никак не укладывается в одно действие и должен сделать множество операций прежде чем дать доступ следующему. В этом случае процесс ставит некий глобальный Lock на ресурс и никто другой, даже получив законное право на доступ, не может ничего сделать. Все ждут пока этот Lock не будет снят.
Это решается на уровне приложения и правильность реализации полностью в вашей ответственности. Например, если забыли разблокировать или сделали перекрёстный Lock (Deadlock как на картинке), то всё зависнет в бесконечном ожидании.
#basic
🌍 In some places, coastal cliffs are vanishing so quickly that entire villages have moved inland within a single generation, as sea level rise and stronger storms speed up the erosion. ✨
#erosion⚡#coastlines⚡#climate⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The boundary where the Earth's solid land meets the sea—called the coastline—is constantly changing. Waves, tides, and storms reshape these edges every day, making coastlines dynamic and ever-shifting. ✨
#geography⚡#coastlines⚡#change⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Coastal erosion is eating away cliffs and beaches so fast in some places that detailed maps need updating every year, with new shorelines appearing and disappearing before our eyes. ✨
#coastlines⚡#erosion⚡#mapping⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Coastal erosion now removes up to 24 square meters of land per meter of shoreline in some parts of West Africa each year, forcing whole fishing villages to move further inland. ✨
#coastlines⚡#erosion⚡#sea-level ⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Satellite data shows that some coastlines have retreated by over 50 meters in just a decade, as rising sea levels and stronger storms rapidly reshape shores across the globe. ✨
#erosion⚡#sea-level ⚡#coastlines⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Mediterranean coastline holds more than 150 million-year-old fossils, often exposed in seaside cliffs by constant wave erosion. Some beach rocks here contain ancient traces of life dating back to the dinosaurs. ✨
#coastlines⚡#fossils⚡#erosion⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Mangroves protect coastlines from storms and rising seas, but over a third have been lost worldwide. Their destruction leaves many regions more vulnerable to flooding and erosion. ✨
#mangroves⚡#coastlines⚡#erosion⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Salar de Uyuni in Bolivia holds an ancient, dried-up sea that now forms the world's largest salt flat. Rare rainy seasons briefly transform it into a mirror reflecting the entire sky. ✨
#coastlines⚡#saltflat⚡#landscape⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Bohai Sea in China is so shallow that its average depth is just 18 meters—less than a six-story building. This makes it one of the least deep seas in the world’s coastal regions. ✨
#seas⚡#coastlines⚡#shallow⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels