Hi,
I have a piece of code (simplified):
if(reentrantLockObject.isLocked()) {
reentrantLockObject.unlock();
}
where reentrantLockObject is java.util.concurrent.locks.ReentrantLock.
Sometimes I get IllegalMonitorStateException.
It seams that lock was released between check and unlock() call.
How can I prevent this exception?...
In general, is there a decent way in SharePoint to control race conditions due to two processes or even two machines in the farm operating on the same list or list item at the same time? That is, is there any mechanism either built in or that can be fabricated via the Object Model for doing cross-process or cross-machine locking of indi...
I want to completely replace one directory on the file system with another directory in a temp directory. The tricky part is that the files in the folder to be replaced could be being used at any time, causing the replace operation to fail.
I need to somehow wait on an exclusive lock on the directory so that I can delete all of its cont...
What would be the best approach for saving site categories from sql server 2005 db for use with menu control(asp.net 3.5)?
I already have the full xml sitemap string from dataset.GetXml(), so I 'only' need to take care of writing the xml to the file and avoid locking it up because the whole site navigation depends on this sitemap.
What h...
I would like to know if there is any way a file can be moved only if the destination does not exist - in other words, move only if it does not lead to overwriting.
mv --update
seemed first to be the solution, however, if the timestamp of the source path is newer than the destination, move will overwrite it and all attempts to circumve...
I have a stored procedure that inserts batches of millions of rows, emerging from a certain query, into an SQL database. It has one parameter selecting the batch; when this parameter is omitted, it will gather a list of batches and recursively call itself, in order to iterate over batches. In (pseudo-)code, it looks something like this:
...
I would like to understand how this happened. I was running a query that would take a long time, but should not lock up any table. However, my dbs were practically down - it seems like it was being locked up by "FLUSH TABLES WITH READ LOCK"
03:21:31 select type_id, count(*) from guid_target_infos group by type_id
02:38:11 select type_...
The typical documentation on locking in innodb is way too confusing. I think it will be of great value to have a "dummies guide to innodb locking"
I will start, and I will gather all responses as a wiki:
The column needs to be indexed before row level locking applies.
EXAMPLE: delete row where column1=10; will lock up the table unle...
I have a SQL Server CE Database file that gets re-deployed every time I run. This makes testing difficult.
The only way I have found that allows me to get around it is to open the database file on the device using Query Analyzer. My best guess is that this locks the file.
Opening the db (and putting in the password) takes some ti...
I want to implement a file level locking in my app.
...
I would like to perform an activity at the key guard screen, but the only way I can find to do so is to disable the key guard, do my activity, then re enable the key guard. This would be ok if it didn't cause the key guard screen to flash off and on (disable makes it disappear then re enable brings it back). I am wondering how I can pe...
I'm working on a thread-safe collection that uses Dictionary as a backing store.
In C# you can do the following:
private IEnumerable<KeyValuePair<K, V>> Enumerate() {
if (_synchronize) {
lock (_locker) {
foreach (var entry in _dict)
yield return entry;
}
} else {
foreach (var...
public class A { }
public class B:A { }
void foo()
{
A a = new B();
B b = a as B;
}
for a given instance setup, will lock(a) be equivalent to lock(b) ?
I mean, will locking be mutually exclusive? If I lock(a) in one thread and lock(b) in another thread, will I get a mutually exclusive access to that single instance of B create...
I know this sounds weird, but apparently one of my columns is locked.
select * from table where type_id = 1 and updated_at < '2010-03-14' limit 1;
select * from table where type_id = 3 and updated_at < '2010-03-14' limit 10;
the first one would not finish running even in a few hours, while the second one completes smoothly. the only ...
Hello!
I'm writing an application that will have to be able to handle many concurrent accesses to it, either by threads as by processes. So no mutex'es or locks should be applied to this.
To make the use of locks go down to a minimum, I'm designing for the file to be "append-only", so all data is first appended to disk, and then the ad...
Hi eveybody, if i have a yield return in a lock statement does the lock get taken out on each yield (5 times in the example below) or only once for all the items in the list?
Thanks
private List<string> _data = new List<string>(){"1","2","3","4","5"};
private object _locker =new object();
public IEnumerable<string> GetData(...
I'm writing a program which listens to an incoming TcpClient and handles data when it arrives. The Listen() method is run on a separate thread within the component, so it needs to be threadsafe. If I break out of a do while loop while I'm within a lock() statement, will the lock be released? If not, how do I accomplish this?
Thanks!
(A...
This is a pretty basic question, and I imagine that it is, but I can't find any definitive answer. Is SynchronizationContext.Post() threadsafe?
I have a member variable which holds the main thread's context, and _context.Post() is being called from multiple threads. I imagine that Post() could be called simultaneously on the object. Sho...
I want this blackberry 9700 to "fully lock" as soon as I click the icon for the "Keyboard Lock" application. Currently I have to wait 5 to 7 seconds for the screen to go dark after each time I click the "Keyboard Lock" icon. During that time if something touches the touch pad, then the 5-7 second timer resets and you have to wait anoth...
I have a situation where a block of code should be executed only if two locker objects are free.
I was hoping there would be something like:
lock(a,b)
{
// this scope is in critical region
}
However, there seems to be nothing like that. So does it mean the only way for doing this is:
lock(a)
{
lock(b)
{
// this...