Questions tagged [synchronization]

Synchronization refers to using controls to maintain a coherent representation, either a group of processes running the same program (process synchronization), or representations of data (data synchronization).

In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. Process synchronization refers to the idea that multiple processes are to join up or handshake at a certain point, so as to reach an agreement or commit to a certain sequence of action. Data synchronization refers to the idea of keeping multiple copies of a dataset in coherence with one another, or to maintain data integrity. Process synchronization primitives are commonly used to implement data synchronization.

-from Synchronization (computer science) - Wikipedia

12446 questions
35
votes
6 answers

wait and notify in C/C++ shared memory

How to wait and notify like in Java In C/C++ for shared memory between two or more thread?I use pthread library.
Sajad Bahmani
  • 17,325
  • 27
  • 86
  • 108
35
votes
8 answers

What's the standard algorithm for syncing two lists of related 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 recurring task I'm facing while programming is that I am dealing with lists of objects from…
Oliver Giesen
  • 9,129
  • 6
  • 46
  • 82
35
votes
7 answers

Sharing a variable between multiple different threads

I want to share a variable between multiple threads like this: boolean flag = true; T1 main = new T1(); T2 help = new T2(); main.start(); help.start(); I'd like to share flag between main and help thread where these are two different Java classes…
user1031431
  • 1,475
  • 6
  • 17
  • 24
35
votes
4 answers

Why is there no generic synchronized queue in .NET?

I noticed that you can call Queue.Synchronize to get a thread-safe queue object, but the same method isn't available on Queue. Does anyone know why? Seems kind of weird.
skb
  • 30,624
  • 33
  • 94
  • 146
34
votes
7 answers

Is changing a pointer considered an atomic action in C?

If I have a multi-threaded program that reads a cache-type memory by reference. Can I change this pointer by the main thread without risking any of the other threads reading unexpected values. As I see it, if the change is atomic the other threads…
Andrioid
  • 3,362
  • 4
  • 27
  • 31
34
votes
4 answers

Best way to instantly mirror/sync files from Windows to Linux server

I have a directory on a Windows machine with a large number of files and folders that I need to watch and have the files mirrored/synced instantly (or as near to as possible), to a Linux machine over the local network. I've investigated: - Rsync,…
EvilPuppetMaster
  • 8,072
  • 10
  • 34
  • 31
34
votes
5 answers

Using string as a lock to do thread synchronization

While i was looking at some legacy application code i noticed it is using a string object to do thread synchronization. I'm trying to resolve some thread contention issues in this program and was wondering if this could lead so some strange…
Illuminati
  • 4,539
  • 2
  • 35
  • 55
34
votes
4 answers

Nvidia graphics driver causing noticeable frame stuttering

Ok I've been researching this issue for a few days now so let me go over what I know so far which leads me to believe this might be an issue with NVidia's driver and not my code. Basically my game starts stuttering after running a few seconds…
TylerGlaiel
  • 652
  • 7
  • 16
34
votes
3 answers

Use Robocopy to copy only changed files?

I'm trying to find an easy way of deploying only changed files to the webserver for deployment purpose. In times past I've used MSBuild, which could be told to only copy files that were newer than the ones on the target, but I'm in a hurry and…
Cyberherbalist
  • 12,061
  • 17
  • 83
  • 121
34
votes
7 answers

Synchronization on the local variables

I have a multithreaded Java code in which: several threads read stateful objects from the synchronized shared storage (i.e. as a result of this, some threads may reference the same objects); each thread then invokes a method process() and passes…
Sergey Mikhanov
  • 8,880
  • 9
  • 44
  • 54
34
votes
3 answers

Waiting on a condition in a reentrant lock

The following code is taken from the JavaDoc of Condition: class BoundedBuffer { final Lock lock = new ReentrantLock(); final Condition notFull = lock.newCondition(); final Condition notEmpty = lock.newCondition(); final Object[] items =…
vektor
  • 3,312
  • 8
  • 41
  • 71
34
votes
5 answers

What is java's equivalent of ManualResetEvent?

What is java's equivalent of ManualResetEvent?
ripper234
  • 222,824
  • 274
  • 634
  • 905
33
votes
6 answers

Atomic Operations and multithreading

Recently I was reading a tutorial, in that I came across a statement that says.. "The Java language specification guarantees that reading or writing a variable is an atomic operation(unless the variable is of type long or double). Operations…
MaheshVarma
  • 2,081
  • 7
  • 35
  • 58
33
votes
6 answers

Running code on the main thread from a secondary thread?

This is a general Java question and not an Android one first off! I'd like to know how to run code on the main thread, from the context of a secondary thread. For example: new Thread(new Runnable() { public void run() { //work…
Javawag
  • 1,547
  • 2
  • 16
  • 23
33
votes
3 answers

When do I need to use MPI_Barrier()?

I wonder when do I need to use barrier? Do I need it before/after a scatter/gather for example? Or should OMPI ensure all processes have reached that point before scatter/gather-ing? Similarly, after a broadcast can I expect all processes to already…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805