synchronization

SynchronousQueue fairness

Hi I'm using a 1producer-1consumer design in my app using a SynchronousQueue. By now, I'm using it with the default constructor (fair=true). And I'm wondering about how "fair=false" would affect to the system (performance and specially concurrency behaviour). Here what the docs tell: SynchronousQueue public SynchronousQueu...

How can I tell if a file on an FTP is identical to a local file with out actually downloading the file?

I'm writing a simple program that is used to synchronize files to an FTP. I want to be able to check if the local version of a file is different from the remote version, so I can tell if the file(s) need to be transfered. I could check the file size, but that's not 100% reliable because obviously it's possible for two files to be the sam...

How to determine what part of Java code needs to be synchronized?

How to determine part of what Java code needs to be synchronized? Are there any unit testing technics? Samples of code are welcome. ...

Javscript: Acts different when test alert message is present

Hello, I have a text box function as below <input type="text" onkeypress="return onEnter(event,this);" onBlur="return chkForDBCS(this);"/> function chkForDBCS() check if a DBCS(mainly for japanese char) is entered in the text and throws an alert message and clears the text box. function onEnter() submits the form. When i have t...

how to retain remote permissions of rsynced files

I've read through the man page of rsync but still can't figure out what are the flags for this requirement: set 775 permission of new files/directories in destination host note: local host is windows xp, remote is linux edit: i'm using the following flags for the moment. -rltzC --force --delete ...

Google MultiMap and synchronization

Hi, I dont understand why i get a concurrentModificationException when i iterate trough this multimap. I read the following javadoc entry, but i'm not sure to understand the whole thing. I tried to add synchronized block. But i doubt on what to synchronize with, and when. Dont hesite to be crude if do huge mystake with concurency ;-)...

secure database distribution to external clients

We want to distribute / synchronize data from our Datawarehouse (MS SQL Server) to external customers (also MS SQL Server). The connection has to be secure, because we are dealing with trusted data. Transmission of data from our system to external client system must be via the http/https In addition it is possible that the clients still...

Optimized ReaderWriterLock Read Access (C#)

So it's my understanding that on a ReaderWriterLock (or ReaderWriterLockSlim more specifically), both the read and write need acquire a mutex to take the lock. I'd like to optimize the read access of the lock, such that if there are no writes pending, no lock need be acquired. (And I'm willing to sacrifice the performance of writes, add ...

Event aggregator and collections

Hi, i want to use an event aggregator to syncronize my viewmodel with the view (the viewmodel ovservs the model), this is very simple to implement in the model, simply call notify on the setters of the properties. but it gets more complicated when the model has collections. where should be the code which will call notify? what would be ...

Using synchronization in Data Access Layer

Suppose we are developing class which implements simple CRUD operations for working with DB. This class also maintain cache for increasing performance. public class FooTableGateway { Map<Integer, Foo> id2foo = new HashMap<Integer, Foo> (); public void getFoo (int id) { if (id2foo.containsKey (id) { return id2foo.g...

Programming to interfaces and synchronized collections

This question relates to Java collections - specifically Hashtable and Vector - but may also apply elsewhere. I've read in many places how good it is to program to interfaces and I agree 100%. The ability to program to a List interface, for instance, without regard for the underlying implementation is most certainly helpful for decoupli...

.NET 3.5: What is the "ValidatorCollection.IsSynchronized" Property "synchronized" to?

Hi, I understand that in .NET 3.5 the ValidatorCollection.IsSynchronized property return a Boolean telling me if it is synchronized or not. However, I'm having a hard time understand what is it synchronizing with or to? The MSDN manual simply says: Gets a value that indicates whether the ValidatorCollection collection is synchro...

RSync: How do I synchronize in both directions?

Hello! I want to use rsync to synchronize two directories in both directions. I refer to synchronization in classical sense (not how it is meant in rsync manuals): I want to update the directories in both directions, depending on which of them is newer. Can this be done by rsync (preferable in a Linux-way)? If not, what other solution...

Business objects synchronization between WCF services

Hi everyone ! I am moving my architecture from coupled one to SOA (WCF) loosely coupled. I have several services which communicate with each others. How would you synchronize the business instances between the services? I see two scenarios here: All the business objects are created in only one service, let's call it MainService and ...

Find new rows in database

I am looking for a way to know which rows in a database (mysql) are new (or updated) in order to fetch just those from the server and store locally in an application (client). My initial thought was to add a timestamp to each row and have my application remember the time it last got an update, however I am worried of the server clock c...

Java FileWriter overwrite

Hi Everyone, I have a piece of code that generates new data whenever there is new data available as InputStream . The same file is overwritten everytime. Sometimes the file becomes 0 kb before it gets written. A webservice reads these files at regular intervals. I need to avoid the case when the file is 0 bytes. How do it do this? Wil...

Java Double Checked Locking

Hi All, I happened upon an article recently discussing the double checked locking pattern in Java and it's pitfalls and now I'm wondering if a variant of that pattern that I've been using for years now is subject to any issues. I've looked at many posts and articles on the subject and understand the potential issues with getting a re...

Offline database synchronization with Server

We are having a client-server architecture where client goes offline when connects remotely to server. Server is essentially a SQL Server 2008, with few tables each with thousands of records. Each client application (WPF) would require to store replica of Server data for their offline use (in SQL Express?). And ideally when client applic...

Correctly synchronizing equals() in Java

I have the following class which contains only one field i. Access to this field is guarded by the lock of the object ("this"). When implementing equals() I need to lock this instance (a) and the other (b). If thread 1 calls a.equals(b) and at the same time thread 2 calls b.equals(a), the locking order is reverse in the two implementatio...

Ensure that Spring Quartz job execution doesn't overlap

I have a Java program that executes from Spring Qquartz every 20 seconds. Sometimes it takes just few seconds to execute, but as data gets bigger I'm sure it run for 20 seconds or more. How can I prevent Quartz from firing/triggering the job while one instance is still being executed? Firing 2 jobs performing same operations on a databa...