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
4
votes
5 answers

C++ select() not waiting for timeout period

I'm trying to use the select function to accept input but every 2 seconds do something else if the user hasn't entered anything. The code below is waiting two seconds the first time select() is reached but once it prints the first "timed out"…
pandaEater
  • 165
  • 2
  • 5
  • 11
4
votes
2 answers

What is a good strategy for caching prepared statements in Tomcat?

I am looking for a way to cache prepared statements in a servlet environment (specifically, Tomcat 5.5). This is meant to reduce the number of times that prepared statements are created, i.e. the number of times that connection.prepareStatement(sql)…
Ovesh
  • 5,209
  • 11
  • 53
  • 73
4
votes
1 answer

How do I declare __sync_fetch_and_add?

I am writing a program that could very much use __sync_fetch_and_add. Unfortunately my autoconf script that searches for it with this fairly straightforward test: AC_CHECK_FUNCS([__sync_fetch_and_add]) Generates this…
vy32
  • 28,461
  • 37
  • 122
  • 246
4
votes
1 answer

Recursive synchronization using GCD

I have some model classes that I need to synchronize. There is a main object of type Library that contains several Album objects (imagine a music library, for example). Both the library and albums support serialization by implementing the NSCoding…
zoul
  • 102,279
  • 44
  • 260
  • 354
4
votes
5 answers

Double checked locking in modern JVMs

I have a class that might throw any run-time exceptions during initialization. I want the class to be a singleton since the cost of keeping several objects in memory is high. I am using that class in another class. My use case is as follows: I…
Swaranga Sarma
  • 13,055
  • 19
  • 60
  • 93
4
votes
2 answers

Guard simple list in threaded programming?

I'm reading a POSIX threading book for some practice, and I was trying to work out where I'd need mutex guards in a simple singly-linked list as a little practice problem. For example, if I had a list of node structures: template
John Humphreys
  • 37,047
  • 37
  • 155
  • 255
4
votes
3 answers

Best way to maintain data integrity between local and remote sql databases

So I have, what would seem like a common question that I can't seem to find an answer to. I'm trying to find what is the "best practice" for how to architect a database that maintains data locally, then syncs that data to a remote database that is…
JoeCortopassi
  • 5,083
  • 7
  • 37
  • 65
4
votes
3 answers

Typewriter effect with JTextArea

I've managed to make a typewriter class that does what I want it to for the most part. It will output the string given to it one character at a time, pausing between each one as if they were typed, pausing a bit longer after periods. The problem I'm…
CaldwellYSR
  • 3,056
  • 5
  • 33
  • 50
4
votes
2 answers

magento: database synchronization between production, staging & development

I've been reading up today on database synchronization in Magento. One thing I am currently struggling with is what needs to be synced during development and during uploads to production. Now assuming that a batch of changes will consist of changes…
Jared Eitnier
  • 7,012
  • 12
  • 68
  • 123
4
votes
1 answer

Syncing directories with python's ftplib

I'm learning python and trying to write a code to sync two directories: one is on ftp server, the other is on my local disk. So far, I wrote a working code but I have a question or two about it :) import os from ftplib import FTP h_local_files = []…
errata
  • 5,695
  • 10
  • 54
  • 99
4
votes
3 answers

Getting a thread to pause - Thread.wait()/Thread.notify()

I'm trying to understand how threads work, and I wrote a simple example where I want to create and start a new thread, the thread, display the numbers from 1 to 1000 in the main thread, resume the secondary thread, and display the numbers from 1 to…
gsgx
  • 12,020
  • 25
  • 98
  • 149
4
votes
1 answer

Strange behaviour in Java concurrency using no synchronization

In Java Concurrency in Practice there is a sample that made me confused: public class Novisibility { private static boolean ready; private static int number; private static class ReaderThread implements Runnable { public void…
Amir Pashazadeh
  • 7,170
  • 3
  • 39
  • 69
4
votes
2 answers

Avoiding a lost update in Java without directly using synchronization

I am wondering if it is possible to avoid the lost update problem, where multiple threads are updating the same date, while avoiding using synchronized(x) { }. I will be doing numerous adds and increments: val++; ary[x] += y; ary[z]++; I do not…
nash
  • 3,020
  • 6
  • 38
  • 53
4
votes
1 answer

Synchronous GM_xmlhttpRequest acting asynchronously?

I'm trying to get a GM_xmlhttpRequest call to behave synchronously, but I can't get it to work like I expect: function myFunction (arg) { var a; GM_xmlhttpRequest ( { method: "GET", url: …
4
votes
3 answers

git: how to push without checking out?

I have two computers A and B, and use git sync some files, init.el for example. A's repos is hosted on unfuddle. B's repos is locally. init.el in A is modified and pushed. init.el in B is modified, too. The question is: how to merge A's changes…
user1122445
  • 141
  • 1
  • 5