. NET Surface Question series (14) Distributed lock

Source: Internet
Author: User

How to resolve a distributed lock timeout problem

We can let the thread that gets the lock open a daemon thread to "power" the lock that is about to expire

When a 29-second elapsed, thread A is not finished, this time the daemon executes the expire instruction and "renews" the lock for 20 seconds. The daemon thread executes from the 29th second, once every 20 seconds.

When thread a finishes performing a task, the daemon thread is explicitly turned off.

In another case, if node 1 suddenly loses power, the daemon thread will stop because thread A and the daemon thread are in the same process. When the lock expires, no one gives it a life, and it automatically releases it.

Http://www.360doc.com/content/18/0528/08/36490684_757590223.shtml

. NET Surface Question series (14) Distributed lock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.