locking

Multi-threaded Objective-C accessors: GCD vs locks

梦想的初衷 提交于 2019-12-03 12:42:39
I'm debating whether or not to move to a GCD-based pattern for multi-threaded accessors. I've been using custom lock-based synchronization in accessors for years, but I've found some info ( Intro to GCD ) and there seems to be pros of a GCD-based approach. I'm hoping to start a dialog here to help myself and others weigh the decision. The pattern looks like: - (id)something { __block id localSomething; dispatch_sync(queue, ^{ localSomething = [something retain]; }); return [localSomething autorelease]; } - (void)setSomething:(id)newSomething { dispatch_async(queue, ^{ if(newSomething !=

Unexpected Locking for Table with Primary Key & Unique Key

南笙酒味 提交于 2019-12-03 12:20:30
I've run into an innodb locking issue for transactions on a table with both a primary key and a separate unique index. It seems if a TX deletes a record using a unique key, and then re-inserts that same record, this will result in a next-key lock instead of the expected record lock (since the key is unique). See below for a test case as well as breakdown of what records I expect to have what locks: DROP TABLE IF EXISTS foo; CREATE TABLE `foo` ( `i` INT(11) NOT NULL, `j` INT(11) DEFAULT NULL, PRIMARY KEY (`i`), UNIQUE KEY `jk` (`j`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; INSERT INTO foo

How can I make a non-blocking request for an exclusive lock using File#flock?

我的未来我决定 提交于 2019-12-03 12:13:45
问题 How Should I Request a Non-Blocking Lock? Why doesn't Ruby's File#flock work as expected when separate attempts are made to lock a file? Locking the file in a block is not the correct solution for this issue because the point is to show the behavior of locking on persistent locks. Using File#flock inside a block releases the lock when the block exits, so it doesn't demonstrate the problem properly. File#flock fails in a variety of ways, especially when requesting a non-blocking lock. Some

Multiple Java threads seemingly locking same monitor?

人走茶凉 提交于 2019-12-03 12:10:35
问题 In a Java threaddump I found the following: "TP-Processor184" daemon prio=10 tid=0x00007f2a7c056800 nid=0x47e7 waiting for monitor entry [0x00007f2a21278000] java.lang.Thread.State: BLOCKED (on object monitor) at org.apache.jackrabbit.core.state.SharedItemStateManager.getNonVirtualItemState(SharedItemStateManager.java:1725) - locked <0x0000000682f99d98> (a org.apache.jackrabbit.core.state.SharedItemStateManager) at org.apache.jackrabbit.core.state.SharedItemStateManager.getItemState

SQL Server locks explained

我与影子孤独终老i 提交于 2019-12-03 12:08:51
Below is a list of locks that SQL Server 2000 is meant to support. I am a bit confused as to what the "intent" locks actually mean. I've looked around on the Web and the answers seem to be a bit cryptic. Further to getting an answer to my specific question, I am hoping to use this question as a Wiki for what each lock means and under what circumstances that type of lock will be acquired. Shared (S) Update (U) Exclusive (X) Intent intent shared (IS) intent exclusive (IX) shared with intent exclusive (SIX) intent update (IU) update intent exclusive (UIX) shared intent update (SIU) Schema schema

Directory lock error with Lucene.Net usage in an ASP.NET MVC site

雨燕双飞 提交于 2019-12-03 12:05:46
I'm building an ASP.NET MVC site where I want to use Lucene.Net for search. I've already built a SearchController and all of its methods, but I'm getting an error at runtime that occurs when the SearchController is first initialized. In SearchController, here's how I'm creating an IndexWriter: public static string IndexLocation = HostingEnvironment.MapPath("~/lucene"); public static Lucene.Net.Analysis.Standard.StandardAnalyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(); public static IndexWriter writer = new IndexWriter(IndexLocation,analyzer); The error occurs on the last

C# method to lock SQL Server table

僤鯓⒐⒋嵵緔 提交于 2019-12-03 11:26:56
I have a C# program that needs to perform a group of mass updates (20k+) to a SQL Server table. Since other users can update these records one at a time via an intranet website, we need to build the C# program with the capability of locking the table down. Once the table is locked to prevent another user from making any alterations/searches we will then need to preform the requested updates/inserts. Since we are processing so many records, we cannot use TransactionScope (seemed the easiest way at first) due to the fact our transaction winds up being handled by the MSDTC service . We need to

Lock() in a static method

ぃ、小莉子 提交于 2019-12-03 10:56:44
I have a multi threaded application that writes to a settings xml file using a static method. I want to avoid that the file is being updated twice at the same time (causing accesss/write exception). How do I do that? This doesn't work: namespace Program { public class Settings { private static void SetSettingsValue (string settings, string value) { // make this thread safe to avoid writing to a locked settings xml file lock (typeof(Settings)) { //write data to xml file } } } } The concept of lock() is to use an existing-object it can reference and use to control whether access is granted.

What is (are) difference between NOLOCK and UNCOMMITTED

▼魔方 西西 提交于 2019-12-03 10:29:41
问题 I use SQL Server 2012. I write two queries but what is a different between NOLOCK and UnCommitted ? SELECT lastname, firstname FROM HR.Employees with (READUNCOMMITTED) SELECT lastname, firstname FROM HR.Employees with (NoLock) 回答1: NOLOCK : Is equivalent to READUNCOMMITTED (source : MSDN ) NOLOCK or READUNCOMMITTED Specifies that dirty reads are allowed. No shared locks are issued to prevent other transactions from modifying data read by the current transaction, and exclusive locks set by

How is class level locking achieved in java?

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am aware of locking concepts with synchronization of static and non static methods to lock classes and instances respectively. What I am not able to understand is, how is class level lock achieved? I mean, class is a template only, with no physical significance. So, when we say that class level locking is achieved with synchronizing static methods what happens then? Do all the objects of that class get locked or some other process? With what I could find out with my search is that there are class objects (Class.class) and lock is