How to use asynchronous methods (JSON Restful services) in iOS?

I have an iOS application that sync data from a JSON restful web service. This method is called from an external class (not UI controller). This class has a sync method and It sends and retrieves data without any problem. My problem is how do I pause

Java - multithreading increment

I have the following class in my application public class InsertErrorLinesHandler { private int currentCount; public void insertErrorLine() { //do something... currentCount++; } } And I have multiple threads that are using the same instance of Insert

why does the thread continue to work after locking?

This is the example in java tutorial of Oracle about Lock object. Someone please confirms whether I interpreted the code correctly. I will consider only the first thread, because the other works the same way. First, it acquires the lock of alphonse,

Locking discussions in Java does not work

I have a simple problem with multithreading that I just cant figure out. I tried synchronizing methods and using locks but none of these worked so I hope someone here could help me. public void startThreads(ArrayList<ArrayList<Tocka>> pLista)

Moodle: Registering an LDAP User Group

I have managed to configured for the LDAP authentication and it is working properly. And then when it comes to LDAP enrollment, I have encountered a problem. Currently, I am testing with 2 courses, defined in LDAP. (Both of them do not exist on moodl

API to trigger OneNote synchronization?

I'm looking for the way to programatically trigger OneNote synchronization from OneDrive (e.g. VBA, Powershell etc). The case is the following: 1) I've done some changes on laptop and would like to sync notebook on the tablet. 2) Now I have to open O

Why this piece of C ++ code is not synchronized

I am learning to write multithreading applications. So share I run into trouble anytime I want my threads to access even the simples shared resources, despite using mutex. For example, consider this code: using namespace std; mutex mu; std::vector<st

Should the input listeners be synchronized?

My sample code posted below shows two classes. One implements KeyListener and the other implements Runnable and is running in an infinite loop sleeping every 20 ms. When a key is pressed the keyChar, which is in the form of an int, is used as an inde

How to safely interrupt a thread with a critical atomic logic?

I have a thread that does two stuff in a loop: wait for objects from a BlockingQueue and then process them. The processing logic has effects that is observable outside the JVM and must be done atomically. Currently this thread is controlled by a vola

Proper use of the Singleton pattern

I am trying to implement an example of the singleton pattern. One of our questions is to run two threads each calling getInstance() and to verify only one instance of the Singleton object was created. Here is my Singleton code; public class OurSingle

Synchronization Parent & amp; Child process

I want to synchronize the parent and child process to alternatively print 1 to 10 into a file. And output which process printed the number. The following code prints alternatively, but the same number. Please help me out! #include <stdio.h> #include

What is the exact behavior of SetEvent of Windows?

I have an auto-reset event object, and there is one thread waiting on it. If now I call SetEvent, can it be guaranteed that the event object is nonsignaled when SetEvent has returned? I have two threads that run in a A-B-A-B-... way. As soon as A wak

Implementing drive lock

I have a homework problem where I have to implement a reader writer lock. Please note that I am NOT looking/asking for code. I wish to understand the behaviour of reader-writer locks which will help me finalize the implementation details. Lets say th

My sync is not working

I tried to use synchronized and ReentrantLock in Bank.transfer, but i get output like this: "From 7 to 3 transfered 82.0. Total 918", "From 0 to 4 transfered 27.0. Total 973" While Total must be equal to 1000. Tell me what am I wrong?

How to implement a Lock with a Python 2.7 timeout

Is there a way to implement a lock in Python for multithreading purposes whose acquire method can have an arbitrary timeout? The only working solutions I found so far use polling, which I find inelegant and inefficient Doesn't preserve the bounded wa

how to share a mutex lock for a group of pthreads?

I'm trying to do some stuff with pthreads and sync them: How could I use mutex just for a group of threads ? Let's say I have t0,t1, t2, .. t20. pthreads running at the same time, and I want to have a lock for the even numbers threads and other lock

Synchronization issues with a static method in Java

Suppose I have a Utility class, public class Utility { private Utility() {} //Don't worry, just doing this as guarantee. public static int stringToInt(String s) { return Integer.parseInt(s); } }; Now, suppose, in a multithreaded application, a thread

C # threads that synchronize two cameras

I need to capture images from two cameras and combine them together. The flow is like this: two threads, one for each camera, sample the camera frames. Each one sends the frame to a third thread, the consumer. Only when the consumer has two frames he

how to synchronize mysql database queries?

I have a lot of entries in a table that are fetched for performing jobs. this is scaled to several servers. when a server fetches a bunch of rows to add to its own job queue they should be "locked" so that no other server fetches them. when the

Java consistent synchronization

We are facing the following problem in a Spring service, in a multi-threaded environment: three lists are freely and independently accessed for Read once in a while (every 5 minutes), they are all updated to new values. There are some dependencies be

COM + WaitForSingleObject

I've been trying to find a good architecture for one application for the last few days, and after some research I'm finally stuck, and the reason is COM. The app in question will have multiple GUI threads, and they will schedule work items for worker

Mutex on a shared resource of 1 byte

Is Mutex required on 1 byte shared resource? If not then why not? Consider I am using normal desktop PC pentium IV , 32 bit. Will condition change if use core 2 duo?It depends what you are going to do with it, but if you have multiple writers, implem

How to use TestAndSet () to solve the critical section problem?

I'm studying for an exam and I'm having difficulty with a concept. This is the pseudo code I am given: int mutex = 0; do { while (TestAndSet(&mutex)); // critical section mutiex = 0; // remainder section } while (TRUE); My instructor says that only t

Keep synchronized tables in Oracle

We're about to run side-by-side testing to compare a legacy system with a new shiny version. We have an Oracle database table, A, that stores data for the legacy system, and an equivalent table, B, that stores data for the new system, so for the dura

EJB and synchronization

Are Session Beans (stateless session beans, stateful session beans) Synchronized?Only one thread at a time will be accessing your beans. It is up to the application server to manage this. So you should not be using synchronized from within your beans