locking

Java blocking issue: Why would JVM block threads in many different classes/methods?

Hi all, Update: This looks like a memory issue. A 3.8 Gb Hprof file indicated that the JVM was dumping-its-heap when this "blocking" occurred. Our operations team saw that the site wasn't responding, took a stack trace, then shut down the instance. I believe they shut down the site before the heap dump finished. The log had no errors/ex...

Efficient cache synchronization

Consider this public Object doGet() { return getResource(); } private Object getResource() { synchronized (lock) { if (cachedResourceIsStale()) { downloadNewVersionOfResource(); } } return resource; } Assuming that doGet will be executed concurrently, and a lot at that, and that downloadin...

NHibernate exclusive lock

Hi can any of you tell me how I can achieve the same or atleast mimic the behaviour. What i want to achieve is that there are two independent tasks each having no clue of the others existence and one of the tasks reads from a table and the other deletes and writes into this table. I want the delete and write to occur only when there are...

Screen fails to lock

Hi fellow Android developers, I have a mind-boggling issue here and googling yield no result. Basically I have an app which needs to perform a screen lock function at some point (setting FLAG_FULLSCREEN and the relevant settings). This works on Motorola Droid but not Motorola Milestone XT720. On the Milestone, pressing the home button...

Java file locking

Hi, I've written the following helper class that should allow me to get an exclusive lock on a file, then do something with it. public abstract class LockedFileOperation { public void execute(File file) throws IOException { if (!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); ...

Java file locking

Hi, I've been trying to use FileLock to get exclusive access to a file in order to: delete it rename it write to it Because on Windows (at least) it seems that you cannot delete, rename, or write to a file that is already in use. The code I've written looks something like this: import java.io.File; import java.io.FileNotFoundExcept...

how to maintain database integrity for write operations in a website

A website to change add records delete etc website is not connected architecture, so i cant expect sql to refuse writes to a table being edit by some one else also. As data is only written when its sent back to server by the grid.. so is there a way using c# and asp.net, some code , by which i cant explicitly tell the sql server to...

When should we use mutex and when should we use semaphore

When should we use mutex and when should we use semaphore ? ...

When implement a thread safe queue or list does it required to lock before returning Count?

Hi; When implementing a thread safe list or queue; does it requaired to lock on List.Count property before returning the Count i.e: //... public int Count { lock (_syncObject) { return _list.Count; } } //... is it nessesary to do a lock because of the original _list.Count variable maybe not a volatile variable? T...

Making a password lock for an app?

Hello there! I'm wanting to make a password unlock screen for my app, and I'm not sure how I'd go about it. I'm wanting it to look like the Apple-designed version of it, which is the passcode lock setting screen. How might I go about doing something like this, where as soon as all four digits are entered the code is immediately chec...

Will this code not result in a deadlock? Java Threads locking

So the thing is, I want to be able to do this with my class. object.lockAccess(); object.doSomething(); object.doAnotherThing(); object.doAnotherThingYet(); object.unlockAccess(); So the other thread will not be able to access my class methods while locked. Here is the implementation I did, I was wondering if someone got a better idea,...

How to test concurrent access to resource (cache) in Perl?

How can I test that resource (file based cache for caching output of a webapp in Perl) behaves sanely under concurrent access to said shared resource? I wrote a simple file-based cache, written in Perl, which uses locking to serialize write access, i.e. to have only one process that (re)generates cache entry. This cache is to be used...