Multi-threading related questions including technique, structure, and safety issues.

learn more… | top users | synonyms (3)

3
votes
0answers
75 views

Does synchronization in java protect modified class fields? [migrated]

I saw this on Java's synchronization tutorial: public class SynchronizedCounter { private int c = 0; public synchronized void increment() { c++; } public synchronized void ...
5
votes
3answers
208 views

Is it safe to rely on static analysis to “reproduce” concurrency bugs reliably?

I've inherited some Java code which I suspect harbours some concurrency bugs when synchronizing between a thread that queries data and an IO event that updates the same data. I'm trialling a static ...
0
votes
0answers
25 views

API providing function to be run in a thread vs. thread that runs this function

I'm writing a Python library which exposes a certain event listener interface. The user can register callbacks to handle different types of events. There is also a function which handles the actual ...
20
votes
4answers
2k views

What prevents a race condition on a lock?

I understand the basics of what data races are, and how locks/mutexes/semaphores help prevent them. But what happens if you have a "race condition" on the lock itself? For example, two different ...
0
votes
0answers
24 views

Why is sem_post pthread_mutex_lock protected while sem_wait is not?

All the pthread semaphore examples I have seen protect the sem_post call with a pthread_mutex_lock, but the sem_wait is left unprotected! It seems to me that sem_wait also should be protected in some ...
7
votes
2answers
355 views

Can someone explain in simple terms what is the disruptor pattern? [closed]

I would also be interested to know if there are other implementations (i.e. frameworks) or if it is just the one from LMAX.
0
votes
3answers
100 views

In which object should I implement wait()/notify()?

I'm working in an Android project with multithreading. Basically I have to wait to the server to respond before sending more data. The data sending task is delimited by the flag boolean ...
0
votes
1answer
81 views

What should I know and consider, when going from coding single user, to multi-user applications or systems? [closed]

I'm a computer scientist, and I have just started my first job, after a 2,5 year school program. My experience mith computers is very limited before I started school, but I finished with top grades. ...
0
votes
1answer
93 views

Good approach for hundreds of comsumers and big files

I have several files (nearly 1GB each) with data. Data is a string line. I need to process each of these files with several hundreds of consumers. Each of these consumers does some processing that ...
2
votes
0answers
73 views

How can I make a universal construction more efficient?

A "universal construction" is a wrapper class for a sequential object that enables it to be linearized (a strong consistency condition for concurrent objects). For instance, here's an adapted ...
0
votes
3answers
238 views

What is Atomicity?

I'm really struggling to find a concrete, easy to grasp, explanation of Atomicity. My understanding thus far is that to ensure an operation is atomic you wrap the critical code in a locker. But ...
0
votes
2answers
102 views

MVC pattern synchronisation

I am facing a problem in synchronizing my model and view threads I have a view which is table. In it, user can select a few rows. I update the view as soon as the user clicks on any row since I don't ...
0
votes
2answers
133 views

How other thread can show the incremented value unless the 1st thread reaches the return statement?

My code is given below. In the for loop I am getting unexpected output i.e. before completing the execution of for loop by 1st thread the 2nd thread comes in for loop and shows incremented value. ...
0
votes
2answers
88 views

When one thread out of four is executing first line in run() then at the same time what will remaining three threads do?

I have four thread instances and they are executing run() code given below: public void run (){ System.out.println("1st line :"+Thread.CurrentThread().getName()); System.out.println("2nd line ...
0
votes
1answer
166 views

When should I use ZeroMQ and when should I use Akka?

My understanding of Akka is that it allows you to define groups of mini-threads ("Actors") and then have them communicate with each other (and do work) using events. My understanding of ZeroMQ is ...
1
vote
1answer
133 views

WCF service - best way to accept requests from a client and do background work?

For a project at work, I was tasked to create a WCF service that will receive email messages from client and queue them on a database, while at the same time the service will check the DB every 30 ...
3
votes
1answer
145 views

Can the possibility of a data race be ignored in some cases? (while having concurrent threads) [duplicate]

I am programming a game engine as a hobby project, and I would like to separate physics and drawing into two separate threads. The position vectors of entities are subject to modifications by the ...
0
votes
0answers
60 views

Primes and multi-threading

I use to compute primes using linear code which took a long time. As I've an 8 cores processor I thought about multi-threading. At first I use to put a huge number of int in a vector then share the ...
0
votes
1answer
98 views

Using a progress dialog and multi threading

My .NET Windows desktop application creates an HTML report, and has 3 main phases. It may create multiple reports. I show a progress bar so the user knows (estimates) how long it will take (as well ...
0
votes
0answers
268 views

Make a java program use more processors

I am running a program that is supposed to solve a problem with the brute force approach. My computer has a quad-core CPU. When I run the program clearly java uses only one core, because in my ...
0
votes
1answer
101 views

Use of separate threads or singe thread

In my project, on a security system, I was using a socket to get the details of the client and then store it in a database (his IP and port he connected from and service he accessed). I was wondering ...
0
votes
1answer
152 views

Do threads delete themselves?

Let's say I was working on a Swing application. Most of it is run on the EDT using SwingUtilities.invokeLater() inside the main method, because I heard (please correct me if I'm wrong) that that's ...
1
vote
1answer
59 views

Good strategy to implement a listener processing tasks provided by the database

Let's assume this conceptual scenario: The database is constantly populated with "a ton" of tasks named PleaseSendAnEmail. A scheduler/listener in background is aimed to handle those tasks. Of ...
0
votes
2answers
69 views

Locking techniques

Delphi RAD libraries implement many thread friendly objects in a way which forces one to declare another object for storing the reference returned by that object's locking method. The object thus ...
0
votes
1answer
18 views

Difference between TSimpleRWSync's BeginWrite and BeginRead methods?

I have recently switched to TSimpleRWSync from TRTLCriticalSection. The methods BeginRead and BeginWrite confuse me as wherever I read help, they seemingly do the same thing i.e. acquire the critical ...
17
votes
4answers
3k views

Programs that claim they are not “multi-core” friendly

You see this phrase or similar kicked around from time to time, generally referring to a program that claims they were not designed to take full advantage of multi-core processors. This is common ...
0
votes
0answers
17 views

Threading and async intterupting on same process and thread, along with related

So, I'm trying to understand threads. I realize they are a mix of hardware and OS decisions. I also know that a thread, or process, has a set of register/stack variables and functions. In each thread, ...
1
vote
1answer
376 views

Running a process multiple times at the same time

I have a c++ program with opencv library which takes an image as input and perform pose estimation,color detection,phog. When I run this program from the command line it takes around 4-5sec to ...
1
vote
3answers
175 views

Is it possible to perform mutual exclusion of threads without OS support?

I suppose you could adapt distributed mutual exclusion algorithms (Ricart/Agrawala, etc), but aside from these more exotic approaches, are you required to use primitives provided by the OS in order to ...
1
vote
1answer
97 views

Non-Recursive vs Recursive Locks?

I am thinking of using non-recursive locks; I have found them to be having performance superiority over the standard recursive locks (e.g. SimpleRWSync). I have mainly been using critical sections but ...
1
vote
0answers
125 views

Managing child worker thread list

After so much research, I thought I should ask the experts. I am working on a project for my corporate employer, we have android and iPhone mobile apps that make request to a web service, the request ...
1
vote
2answers
148 views

Emulating communication between Android and microcontroller using threads or services or… other?

I am not sure what is the best way for the tasks below: threads, AsyncTasks, Loopers, services? Why? Are there other candidates? I need threads/Tasks/Services/other for: Plotting data, (refreshing ...
-2
votes
1answer
202 views

Extracting data from log files

I will be extracting certain bits from log files using regular expressions to filter out bit of data. Initially I was going to do this with Python. I later started to think about the fastest way I can ...
0
votes
0answers
401 views

Best method for async initialization of view model in MVVM pattern (WPF)

I'm working on a business application (C#, WPF, EF, MVVM). I need to load a bunch of items from database, create view models for them and put them in a window. Is there a way to create the view model ...
6
votes
1answer
1k views

Are go-langs goroutine pools just green threads?

The commentator here offers the following criticism of green threads: I was initially sold on the N:M model as a means of having event driven programming without the callback hell. You can write ...
0
votes
0answers
98 views

Why user threads are mapped to Kernel threads

Since user threads are mapped to kernel threads, why don't we create all threads as kernel threads that is a process with zero user thread. Doesn't mapping of user thread to kernel thread create ...
3
votes
1answer
720 views

Database design/relationship for threading messages

What's the database design or business logic for creating an app for messaging between users? I am having difficulties with choosing how to approach the relationship between each Conversation of User ...
2
votes
2answers
698 views

How Stack and Heap is allocated for threads under the same process in Windows?

Stack for different thread is different.but what about Heap. If Heap is different for different threads, then how they share objects?
2
votes
1answer
187 views

Transactional Memory vs Mutex and Locks

Just found out that Intel processors now have Transactional Memory support !!!! I learned about Transactional operations in my dB/OS class, it is a very simple concept: entire operation is executed or ...
14
votes
1answer
743 views

How can I tell if I am overusing multi-threading?

I currently feel like I am over-using multi-threading. I have 3 types of data, A, B and C. Each A can be converted to multiple Bs and each B can be converted to multiple Cs. I am only interested in ...
1
vote
1answer
119 views

Optimising news fetching

I have a web scraper for scraping news from different sources in wp7. My current appraoch for doing this is: load newspapers information from xml file. go to the specified sections and fetch the ...
0
votes
2answers
166 views

Why would Java app make RPC call to itself?

I am working with a multithreaded homegrown multi-module app in my new job. We use the the Thrift protocol to communicate RPC calls between different stand-alone applications in a distributed system. ...
1
vote
0answers
85 views

Alternatives to Pessimistic Locking in Cluster Applications

I am researching alternatives to database-level pessimistic locking to achieve transaction isolation in a cluster of Java applications going against the same database. Synchronizing concurrent access ...
2
votes
3answers
205 views

How do I limit the resources available to a program?

I'm delving into multi-threaded programming with Java, but I'm finding it hard to test my program for bugs. My computer simply has too many resources and cores, making it hard to see how my program ...
1
vote
0answers
427 views

Java UDP Multithread Server

I have multiple threads. Each thread receives data and sends to client an acknowledge packet. Each thread takes aprox. 531ms from start to finish. While capturing packets with wireshark. I was ...
0
votes
1answer
654 views

C# Design for SQL connection and commands

Currently I'm working on system that works with database, and I would like to have it done elegant way. So I have abstracted DBConnection into one class, DBCommands into another class. (DBCommands : ...
1
vote
1answer
679 views

c++ web with nginx - Do I have to worry about thread safety?

I am currently developing my website with c++. I know that nginx handles connections with multiple threads to provide high performance. And not all c++ code is thread safe. What's the relationship ...
3
votes
1answer
120 views

Do you have to ban atomics to get good tool support for race detectors?

It seems that Helgrind treats atomics the same way as normal read/write operations. So, using atomics will result in lots of false positives. I don't know exactly how ThreadSanitizer deals with ...
6
votes
1answer
1k views

Sleeping Barber Problem (with multiple barbers)

The Sleeping Barber Problem is a classical synchronization problem that many of you may be familiar with or at least heard of. It's based on the premise that a barber (a thread) sleeps when there ...
0
votes
2answers
507 views

Memory allocation of Classes that don't have any global data and locks

static void Main(string[] args) { var c2 = new Class2(); var c3 = new Class3(); var c1 = new Class1(c2, c3); c1.Method1(); } class Class1 { ...