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

learn more… | top users | synonyms (3)

-1
votes
1answer
18 views

Event-based Entity-Component-System with every System in single thread

I've read a german article about the Entity-Component-System design-pattern. In this article, the author wrote, that it would be good to let the systems communicate via Events with each other. So, ...
-4
votes
0answers
21 views

how to remove threads in vector list container in java [on hold]

Enumeration e = v1.elements(); while(e.hasMoreElements()){ Serverthread stm = (Serverthread)e.nextElement(); stm.send(str); } Enumeration ex=names.elements(); int ...
0
votes
0answers
50 views

Using Singletons in JS with workers

I'm building a javascript application that does continuous drawing, but relies on asynchronous scripts in the background which also need to poll for events and write to "global variables". This got me ...
2
votes
4answers
484 views

Why aren't we building and using parallel processors *meant* for general computation?

We all know GPUs are much faster than CPUs for a wide range of applications. When someone asks why we are not just programming for GPUs at all, one of the most common answers is that GPUs are not good ...
3
votes
2answers
163 views

Are there alternatives to using an optional type in a multithreaded environment?

I'm making an MPMC queue in C++, and I would like to find out what the best interface for a try_dequeue method would be (I'm not concerned about its implementation). I'd like to provide a method which ...
0
votes
3answers
124 views

How should be the approach to start thinking about multi thread programming [closed]

I am an experienced java developer.Of now I have started learning multithreading in java.I am able to grasp most of the concepts but still I am unable to visualize applications running on threads.I ...
1
vote
1answer
116 views

Multithreaded Pre/Post Functions

I'm programming an application for an embedded device. We are using an RTOS that supports multi threading. The device is supposed to mimic an older project that was programmed in plain C (without ...
4
votes
1answer
125 views

Error Handling Strategies in Multithreaded Environments

TL;DR What error generating and handling strategies do you use in Multithreaded code intended for use by others and why do you use them? If applicable, state what programming paradigm it's useful for. ...
0
votes
1answer
71 views

Synchronized access to network industrial equipment

I have an industrial equipment which is controlled by a software. The software connects to it using sockets, and keeps the connection all the time alive, while from time to time sending commands to ...
22
votes
6answers
4k views

Multithreading: am I doing it wrong?

I'm working on an application that plays music. During playback, often things need to happen on separate threads because they need to happen simultaneously. For example, the notes of a chord need to ...
18
votes
1answer
996 views

Is there a difference between fibers, coroutines and green threads and if that is so what is it?

Today I was reading several articles on the Internet about fibers, coroutines and green threads, and it seems like these concepts have very much in common, but there are slight differences, especially ...
1
vote
2answers
45 views

Should I reference a CopyOnWriteArraySet from the Set interface?

There are two ways to use a CopyOnWriteArraySet: // A Set<Object> set = new CopyOnWriteArraySet<>(); and // B CopyOnWriteArraySet<Object> set = new CopyOnWriteArraySet<>(); ...
0
votes
1answer
178 views

How can I set a time limit for a game?

I am learning the multi-threading and timer in C# now. But it seems I can't find a good solution. For example, I would like to see how many addition problems that I can solve within 1 min. I would ...
1
vote
1answer
62 views

Should CountDownLatch be used for waiting for an event?

I have a situation here, where I have a loop that loops x amount of times. The value x is determined by the user. Everytime it loops, I want it to wait for a button click before continuing the loop. ...
2
votes
0answers
133 views

Scheduling a few CPU-intensive tasks

I need to schedule a small number of CPU-intensive tasks to run every so often, reading from shared data and writing to dedicated buffers. I don't necessarily want to roll my own scheduling, but am ...
0
votes
2answers
59 views

UI Applications and operations in background threads

I am not really sure about what is the best way to deal with operations executed in background threads in an application I am writing. I am writing it in C# and I am following the MVVM design ...
2
votes
2answers
172 views

Implementation strategies for atomic counter

I basically have a counter variable that is decremented and frequently polled. There are three options to implement that, that I can think of: Number 1: private volatile int count; public void ...
0
votes
1answer
153 views

Why (most?) retro computer emulators are single threaded?

All real computer hardware works in parallel. So why most emulators of retro systems (like NES) are single threaded (or I'm not right?)? You have main loop and you counting CPU cycles and after ...
5
votes
3answers
235 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
28 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
36 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
559 views

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

I would like if you could explain to me in a simple way how does the disruptor patter work. This concept has been elusive to me as of know. Perhaps with your help I could comprehend it.
0
votes
3answers
110 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
132 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
108 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
255 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
159 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
151 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
95 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 ...
1
vote
1answer
406 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
326 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
153 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
63 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
135 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
337 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
107 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
259 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
65 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
79 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
23 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
472 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
183 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
106 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 ...
0
votes
0answers
157 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
151 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
212 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
473 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 ...