synchronization

Local database cache and filters

Isn't it possible to use filters when using the Local database cache wizard to generate Sync framework code? I've been searching and reading documentation for hours without any clarification. If it matters I am syncing between a SQL 2008 database to a SQL CE compact 3.5 database on a mobile 6.1 device over WCF. ...

C# sharing locks with multithreading

Is there a common way to "share" a lock between different objects operating on same set of data? I am aware that having a public object for locking is usually not recommended. For example, a Queue could be implemented as thread safe, but some other class might need a specific lock in order to lock several Queue operations. What happens...

Threads and simple Dead lock cure

When dealing with threads (specifically in C++) using mutex locks and semaphores is there a simple rule of thumb to avoid Dead Locks and have nice clean Synchronization? ...

Why is this program in error? `Object synchronization method was called from an unsynchronized block of code`

What is wrong with this code? i get a 'Object synchronization method was called from an unsynchronized block of code'. I found one result on google that said i may be releasing a mutex before locking but according to my output this is not the case. Here is the mutex code without the other code in between. -edit- sorry guys, wrong paste....

Microsoft Sync Framework - Local DB and Remote DB have to have the same schema?

When using MSF, is it implied in the technology that the sync tables are supposed to be 1-1? The reason I'm wondering is that if I'm synching from a SQL2005 database to a SQLCE, I might want the CE one to be a little more flattened out so I can get data out with a simpler SELECT statement (as CE does not support sprocs). For example, I...

volatile boolean

If I have a volatile boolean (let's call it valid), is the following piece of code thread-safe in Java? if (valid) return; valid = true; Or, do I need to synchronize since valid is set to true only if it's false (hence set of valid depends on its current value)? ...

Does the JVM create a mutex for every object in order to implement the 'synchronized' keyword? If not, how?

As a C++ programmer becoming more familiar with Java, it's a little odd to me to see language level support for locking on arbitrary objects without any kind of declaration that the object supports such locking. Creating mutexes for every object seems like a heavy cost to be automatically opted into. Besides memory usage, mutexes are an ...

Synchronization on "reference" or on instance

Consider the following code: public class Foo { private static final Object LOCK = new Object(); private Object _lockRef1 = LOCK; private Object _lockRef2 = LOCK; private int _indx = 0; public void dec() { synchronized(_lockRef1) { _indx--; } } public void inc() { synchronized(_lockRef2) { _indx++...

Does the String pool take local variables?

I believed the String pool abandoned local Strings when their methods completed Yet: public class TestPool implements Runnable{ /** * @param args the command line arguments */ public void run() { String str= "hello"; synchronized(str){ try { System.out.print(Thread.current...

C++/CLI efficient multithreaded circular buffer

I have four threads in a C++/CLI GUI I'm developing: Collects raw data The GUI itself A background processing thread which takes chunks of raw data and produces useful information Acts as a controller which joins the other three threads I've got the raw data collector working and posting results to the controller, but the next step i...

Support for C++ refactoring in VS (auto-updating references and header/cpp)

In Visual C# I can rename an entity at its definition, and with two clicks all references to that entity get updated. How do I do this in Visual C++? If it's not supported, is there another IDE that supports it? Note that in the C++ case I also want automatic header/implementation synchronization, so I hardly ever need to do duplicate w...

thread synchronization

let's say i have a blocking method , let's call in Block(). as i don't want my main thread to block i might create a worker thread, that instead will call Block. however, i have another condition. i want the call to block to return in 5 seconds top, otherwise, i want to let the main thread know the call to Block failed and to exit the...

C# Socket, time elapsed during sending

Hello. I'd like to know if there was a way to know the time elapsed during the travel of a data on the network. For example, I send a packet from computer A to computer B and C (so elapsed time might be different for each depending on the distance, etc), and I want to know the time between sending and receiving for each client (to sync...

Critical Sections that Spin on Posix?

The Windows API provides critical sections in which a waiting thread will spin a limited amount of times before context switching, but only on a multiprocessor system. These are implemented using InitializeCriticalSectionAndSpinCount. (See http://msdn.microsoft.com/en-us/library/ms682530.aspx.) This is efficient when you have a critic...

When does a dictionary throw an IndexOutOfRangeException on Add or ContainsKey ?

On a busy ASP .NET website, I have a Dictionary, which acts as a cache, basically storing key/value pairs for later retrieval. On high load, the Dictionary some times get into a state, where it always throws an IndexOutOfRangeException whenever i call the ContainsKey or Add method. The exception happens inside the private FindEntry meth...

Java sync games: synchronized && wait && notify

I'm coming from .NET world, and unfortunately looking Java source with .NET's eyes. Following code is from Android Apps (though not Android specific at all): private class Worker implements Runnable { private final Object mLock = new Object(); private Looper mLooper; Worker(String name) { Thread...

thread synchronization - delicate issue

let's i have this loop : static a; for (static int i=0; i<10; i++) { a++; ///// point A } to this loop 2 threads enters... i'm not sure about something.... what will happen in case thread1 gets into POINT A , stay there, while THREAD2 gets into the loop 10 times, but after the 10'th loop after incrementing i's value to 10, befo...

Synchronization mechanisms - Windows CE

What is the fastest synchronization mechanism working on Windows CE? Maybe you know some good articles on this topic ... ...

Getting an iPhone app communicating with an Adobe Air desktop app

I am creating a desktop version of an iPhone app and would like to have some sort of sync option. The desktop version of the app is an Air app. I know that I can have them communicate by: Starting a server on the desktop or the phone Ask the user to enter the IP of the device into the other one Make GET and POST requests over the htt...

What's the standard algorithm for syncing two lists of objects?

I'm pretty sure this must be in some kind of text book (or more likely in all of them) but I seem to be using the wrong keywords to search for it... :( A common task I'm facing while programming is that I am dealing with lists of objects from different sources which I need to keep in sync somehow. Typically there's some sort of "master ...