Возможно, стоит пояснить разницу между синхронизацией из thread/process-safe и синхронизацией с помощью Lock🤔
Наша задача — заставить разные процессы и потоки обращаться к базе данных (или любым другим ресурсам) последовательно. Чтобы не случилось так называемого race condition, то есть состояние гонки. Это когда разные потоки или процессы пытаются одновременно что-то сделать с одним и тем же ресурсом.
В этом случае нам нужна какая-то логика ограничения. Пока один процесс не завершил своё действие, другие не могут получить доступ к ресурсу.
Так вот, thread-safe и process-safe означает что отдельно взятые операции записи в БД гарантированно будут последовательны. Запросы из разных процессов или потоков выстроятся в очередь и не будут мешать друг другу. Лучше всего когда этот блок реализован на уровне БД в виде атомарных операций или ещё как-то.
Но зачем нам тогда еще дополнительный Lock?
Этот способ синхронизации используется когда процесс никак не укладывается в одно действие и должен сделать множество операций прежде чем дать доступ следующему. В этом случае процесс ставит некий глобальный Lock на ресурс и никто другой, даже получив законное право на доступ, не может ничего сделать. Все ждут пока этот Lock не будет снят.
Это решается на уровне приложения и правильность реализации полностью в вашей ответственности. Например, если забыли разблокировать или сделали перекрёстный Lock (Deadlock как на картинке), то всё зависнет в бесконечном ожидании.
#basic
Scientists found a new drug, SW033291, that protects the brain’s blood barrier by blocking an enzyme called 15-PGDH. This stops brain damage and memory loss in mice with Alzheimer’s and brain injuries. Unlike other drugs, it does not remove amyloid protein but still keeps the brain safe and working well. The drug worked even when given a day after injury.🧠💊
[Source]
@googlefactss
#Alzheimers#BrainHealth#Memory#Science
lethonomia (n)
pronunciation: leh – tho – NO – mee – uh
language: English
definition: the inability to recall someone’s name
sentence: It’s very embarrassing to be stricken with acute lethonomia when I have to make introductions at a party. 🧠🗣️
[Source]
@googlefactss#Lethonomia#Memory#LanguageDisorders#BrainHealth#CommunicationChallenges
Learning another language may slow brain aging, according to a huge new study. Multilingual people show less cognitive decline compared to those who speak only one language. The study suggests that speaking multiple languages helps keep brain networks active, especially those responsible for memory and attention, protecting the brain from aging effects.
🧠🌍💬
[Read more]
@googlefactss
#BrainHealth#Multilingual#CognitiveScience#Learning#HealthyAging
Some studies found that watching a lot of (internet)pornography can change the brain. Brain scans showed stronger links in areas that control emotions and decisions. People who watch often feel more pleasure but have less self-control. After watching, their thinking and attention get worse. Their facial expressions also show less emotion, like surprise or disgust, even if they say they enjoyed it. These changes are similar to drug addiction. Repeating this behavior can make emotional responses dull and reduce mental sharpness.
More research is needed, but finding people who never watched porn for studies is very difficult to impossible..
🧠📉
[Read more1]
[Read more2]
[Read more3]
[How to stop watching]
@googlefactss
#BrainHealth#Addiction#Pornography#porn#MentalHealth#Neuroscience
👮♂🚫Warning: Even though this post and the following poll are sexual in nature. Rules still apply. Be respectful or face the consequences..