locking

C# lock and code analysis warning CA2002

六月ゝ 毕业季﹏ 提交于 2019-12-22 04:51:27
问题 In my application I have a form that starts synchronization process and for number of reasons I want to allow only one synchronization to run at a time. So I've added a static bool field to my form indicating whether sync is in progress and added a lock to set this field to true if it wasn't already set so that first thread could start synchronization but when it's running every other thread that will try to start it will terminate. My code is something like this: internal partial class

Apache Zookeeper / Curator time-to-live on locks

断了今生、忘了曾经 提交于 2019-12-22 04:47:14
问题 Is there any facility in the Apache Curator lock recipes (or lower-level ZooKeeper) for auto-releasing locks that have exceeded some TTL? If not, is there a best practice for dealing with that? I see that Curator automatically releases locks in the case of the client connection being lost, which is nice...and the timeout on lock acquisition is also helpful. I'm wondering to what degree I need to protect my system by making a recurring job that looks for locks that have been around to long and

How do I do an exclusive checkout in SVN?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 04:19:09
问题 I'm looking for a way to make an exclusive checkout from SVN. Is there a way to automatically lock a file when it's being checked out ? If one user makes an exclusive checkout, and then another user makes a checkout to the same file, how do I generate some sort of notification or an instant message to the 2nd user that the file is locked? 回答1: If I understand your follow-up posts, what I think you really want is to make sure that people know about locks. I'm imagining a case where users A and

What is the best way to create a lock from a web application?

扶醉桌前 提交于 2019-12-22 04:18:26
问题 I've got a web application that re-sizes images. The re-sized images are written to disk in order to cache them. What is the best way to prevent multiple, simultaneous requests from generating the same image? A couple things to note, we have millions of images (measured in terabytes). Cached images that haven't been viewed in a while are removed. We have a web farm, but each web server has it's own local cache (the originals are stored on another server). We also place the re-sized images in

Lock splitting vs lock striping

社会主义新天地 提交于 2019-12-22 04:07:46
问题 Below is the excerpt from Effective Java by Joshua: If you do synchronize your class internally, you can use various techniques to achieve high concurrency, such as lock splitting, lock striping, and nonblocking concurrency control. Above suggests that lock splitting and lock striping are 2 different techniques but when I tried to find the difference between I couldn't find a difference. Is there is a difference between them or they are same thing? 回答1: Lock splitting is about using different

Overcoming “It is being used by another person or program.” [closed]

天涯浪子 提交于 2019-12-22 01:25:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Is there a way to unlock Windows files without downloading a utility? I have a few files on my Windows XP C: drive that are very old and very useless. When I try to delete these files I get the following message: Cannot delete FILENAME.zip: It is being used by another person or program Close any programs that

Is it good to test a condition then lock then re-test the condition [duplicate]

烂漫一生 提交于 2019-12-22 00:38:19
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Double-checked locking in .net EDIT: lots of edits to clarify this question is not about singleton I find myself writing code like this: if(resourceOnDiskNeedsUpdating) { lock(lockObject) { if(resourceOnDiskNeedsUpdating) // has a previous thread already done this? UpdateResourceOnDisk(); } } return LoadResourceFromDisk(); UpdateResource() is a slow operation. Does this pattern make sense? Are there better

How to get process PID for manual lock mechanism in Python?

你说的曾经没有我的故事 提交于 2019-12-22 00:35:13
问题 I would like to make a simple locking mechanism in Python without having to rely on the existing libraries for locking (namely fcntl and probably others) I already have a small stub, but after searching for a bit I couldn't find a good on answer on how to manually create the lock file and put the process PID inside. Here is my stub: dir_name = "/var/lock/mycompany" file_name = "myapp.pid" lock = os.path.join(dir_name, file_name) if os.path.exists(lock): print >> sys.stderr, "already running

Sybase: trying to lock a record on select so another caller does not get the same one

佐手、 提交于 2019-12-22 00:34:23
问题 I have a simple table in Sybase, let's say it looks as follows: CREATE TABLE T ( name VARCHAR(10), entry_date datetime, in_use CHAR(1) ) I want to get the next entry based on order of "entry_date" and immediately update "in_use" to "Y" to indicate that the record is not available to the next query that comes in. The kicker is that if two execution paths try to run the query at the same time I want the second one to block so it does not grab the same record. The problem is I've found that you

Android Display own lock instead of default when screen on/off

喜欢而已 提交于 2019-12-22 00:25:15
问题 i want to open my created lock instead of default one,when phone is boot at that time my lock is called. But i want to know when my screen on after locked at that time how i called my lock (my lock activity)Means i want to display my lock instead of default at time of screen on or phone restart or switch on all time. like in our phone lock called all time same as i want to call my lock all time( done with boot ).so please any one help me how i call my lock when screen on/off.please help