I'm trying to use MySQL row locking to basically emulate a MuteEx on a row. Lets say that my table has 2 columns, an id and a text field, and three entries (1,a) (2,b) and (3,c).
SELECT * FROM table; would return these results.
I can lock a specific row the normal way.
START TRANSACTION;
BEGIN;
SELECT * FROM table WHERE id = '2' FOR UPD...
Here's an idea I just came up with for a safe, efficient way of handling Singleton synchronization issues. It's basically double-checked locking, but with a twist that involves thread-local storage. In Java/C#/D-style pseudocode, assuming __thread denotes thread-local storage for static variables:
class MySingleton {
__thread stat...
What does this java code means? Will it gain locks on all objects of 'MyClass'
synchronized(MyClass.class) {
//is all objects of MyClass are thread-safe now ??
}
And how the above code different from this one:
synchronized(this) {
//is all objects of MyClass are thread-safe now ??
}
...
I am wondering if you can : lock only a line or a single character in a file in linux and the rest of the file should remain accessible for other processes?
I received a task regarding simulating transaction on a file with c/c++ under linux .
Please give me an answer and if this answer is yes ,give me some links from where i could take a...
When someone visits my website, he will see the page with the fewest pageviews. All pages, including a pageview counter, are stored in a MYSQL database.
If a page is viewed, the pageview counter is increased by one.
I now run into a Racing condition if my webserver has more than one thread:
Thread 1: User A retrieves page P with pa...
The Locks performance object on SQL Server provides three counters that I'm interested in.
X = Average Wait Time (ms)
Y = Lock Wait Time (ms)
Z = Lock Waits/sec
From their descriptions I'd have imagined that X = Y / Z. However, while this is true for SQL2005, it does not seem to be true for SQL2000.
I have some code that forces a dea...
Can I lock/unlock fields or objects at runtime against writing? In other words something like changing objects to read-only temporarily at runtime...
For example:
int x = 5; // x is 5
LockObject(x);
x = 7; // no change
UnlockObject(x);
x = 10; // x is 10
if not can you give me some possible solutions?
...
I've been trying to solve various deadlocks we are seeing in production. We've enabled deadlock tracing. The traces show lots of blocking on KEYLOCKs like this:
01/15/2010 08:25:07,spid15s,Unknown,keylock hobtid=72057594047758336 dbid=2
objectname=tempdb.dbo.MyTable indexname=IX_MyTable id=lock36977900 mode=X
associatedObjectId=720575...
Dear GURUs
I would like to ask couple of questions regarding SQL Server Locking mechanism
If i am not using the lock hint with SQL Statement, SQL Server uses PAGELOCK hint by default. am I right??? If yes then why? may be its due to the factor of managing too many locks this is the only thing i took as drawback but please let me know ...
this is the method:
var ajaxRequest = new Request.HTML({
method: 'post',
url: url + "?dt=" + Date(),
onFailure: function(item) { alert(item.responseText); },
onRequest: function(item) { gui.preloader('on'); },
onSuccess: function(html) {
gui.preloader('off');
element.s...
I have a class which doesn't currently need to be thread-safe, but in future we might want to make a thread-safe version. The way I see it, I can either make it thread-safe now by putting locks around the relevant functions, or I can make them virtual now and put locks around them in overrides in a descendent class later on. That is, t...
Are there any available implementations of a Hashtable that provide thread safety with minimal locking in .NET? Or in another language that can be ported to .NET?
We're looking for something in between using a BCL Dictionary<,> class with lock() and a distributed caching application like memcached or Velocity.
The intended use is for ...
Lets take the sample class SomeThread where we are attempting to prevent the DoSomething methods from being called after the Running property is set to false and Dispose is called by the OtherThread class because if they are called after the Dispose method is the world would end as we know it.
It feels like there is a chance for somethi...
I commented earlier on this question ("Why java.lang.Object is not abstract?") stating that I'd heard that using a byte[0] as a lock was slightly more efficient than using an java.lang.Object. I'm sure I've read this somewhere but I can't recall where: Does anyone know if this is actually true?
I suspect it's due to the instantiation o...
Update: For the benefit of anyone reading this, since .NET 4, the lock is unnecessary due to changes in synchronization of auto-generated events, so I just use this now:
public static void Raise<T>(this EventHandler<T> handler, object sender, T e) where T : EventArgs
{
if (handler != null)
{
handlerCopy(sender, e);
}...
First of all, I am using Oracle and JBoss 4.0.4 and I'm pretty much a newbie on JBoss matters.
Our distributed application uses CMP beans with SimpleReadWrite... etc locking policy, which I'm told seemed the best choice at the time. (Original developers are no longer working with us and I can't easily get feedback from them, not mention...
I'm working on a relatively simple iPhone application that has a multi-round Timer with a number of settings such as the number of rounds and round length. We allow certain settings to be upated while the timer is running which means the timer may be reading from the same memory that the settings are writing. There are no critical sect...
I'm trying to make a multithreaded program that takes a certain bitmap from a picturebox where each thread analyzes and changes part of it and then saves it back to the picturebox.
I've used a lock() for the instructions that deal with the shared bitmap object and the picturebox but for some reason i still get "Object is currently in use...
I have Category class containing list of products. Like this:
public class Category{
...
@0neToMany
@JoinColumn("category_id")
List<Product> products;
public List<Product> getProducts();
...
}
When I call getProducts() I want to lock returned collection so that other transaction could not modify it while current one isn't comm...
Given only compare and swap, I know how to implement a lock.
However, how do I implement a spin lock
1) multiple threads can block on it while trying to lock
2) and then the threads are un-blocked (and acquire the lock) in the order that they blocked on it?
Is it even possible? If not, what other primitives do I need?
If so, how do I...