Singleton class for mutex in c ++

I am struggling to get this working but it seems there is something I don't fully understand. I have a multi-threaded application in a single file (2 classes and the real main in which I create threads and everything). I want to split in 3 files. One

Java concurrent access from ArrayList

After the following code ArrayList<String> foo, bar, test; foo = new ArrayList<String>(Arrays.asList("foo")); bar = new ArrayList<String>(Arrays.asList("bar")); test = new ArrayList<String>(Arrays.asList("t

face multiple player threads and repaint

I am currently working on a java bomber-man game, the game works fine however i do have a concurrent modification exception which is thrown repeatedly. In my game i have two players and each have their own thread which is run (thread.run()) at a cons

InvalidCastException when using the return value of the task

I have spend almost two days reading async/await tutorials and answers on Stackoverflow and trying to understand asynchronous and parallel execution in C#. Still I can not get it to work with my code. What I need Execute a Active Directory search thr

Pure Swift Competition

All the libraries I have come across that provide Swift concurrency functionality either depend on an Objective-C library or are wrappers around the C based GCD. (iOS and OS X) I'm just wondering if anyone knows of a pure Swift concurrency library? N

Java volatile and synchronized

I know that volatile keyword refresh all the invisible data i.e. if some thread read volatile variable all potential invisible variables/references (not only the variable that will be read) will be okey(visible i.e. with correct values) after this re

Java final variables and performance

This question already has an answer here: Does use of final keyword in Java improve the performance? 10 answers Is it good, if the java code is oversaturated with final variables? I think about performance. As far as I know, the final variables are t

Asynchronous methods in Java / Tomcat

I don't want to use a thread runnable in order to execute 2 parallel jobs on my tomcat server (for example: send notification and email). I came a cross with this tutorial. I have added a javax.ejb dependency to my pom.xml, but still there is no @Asy

pthread_cond_signal blocks the thread

I have the following code running for N threads with count=0 initially as shared variable. Every variable is initialised before the working of the threads. I am trying to execute the critical section of code only for MAX number of threads. void *tmai

Delphi Background Workflow 2010

Can someone tell me how to create a thread in Delphi 2010 which will be "standby" for data to be calculated (not to terminate after its calculation task)? I created a program which takes data from an external source via Indy UDPServer. The IdUDP

Python Urllib UrlOpen Read

Say I am retrieving a list of Urls from a server using Urllib2 library from Python. I noticed that it took about 5 seconds to get one page and it would take a long time to finish all the pages I want to collect. I am thinking out of those 5 seconds.

why green threads do not work on multiple hearts

On wikipedia: Green_threads is described as normally cannot run on multi-cores without explaining why. On a multi-core processor, native thread implementations can automatically assign work to multiple processors, whereas green thread implementations

Starting the thread in a servlet, what can be the problems?

I have a web application, that, on a single request may require to load hundreds of data. Now the problem is that data is scattered. So, I have to load data from several places, apply filters on them, process them and then respond. Performing all the

BlockingQueue vs Semaphore

If we want to implement a resource pool such as a database connection pool. Which concurrent collection will you use ? BlockingQueue or Semaphore ? For BlockingQueue, just like the producer-consumer design pattern, the producer will place all the con

Static variables and multiple threads in Objective-C

I'm writing a category for NSNotificationCenter with a class method: +(void)postNotificationName:(NSString*)name onMainThread:(BOOL)mainThread withObject:(id)object; I'm doing this to make sure that I'm explicit with which thread my notifications are

Many small tasks on the GUI

When I must do many short tasks, that are cooperating with GUI, should I use another BackgroundWorker for each task, or some other solution? EDIT I mean update every cell in datagridview (200 rows x 50 columns) every 5 second. Every cell stores image

Get the exception of threads in Java

I have a question with my code. I have two threads running from the main method & I want to catch the exception that can occur in any of the two threads in the main method. Future<Object> incoming=Executors.newSingleThreadExecutor().submit(new T

Background thread in the Azure Web role

It is possible to run a thread from the WebRole.cs OnStart() method in such a way that we are able to access it through aspx page to perform background work? I know that the correct way to do it would be to use a Worker Role but i wish to maintain th

iOS - The wire does not return to the main wire

I having trouble with my threads. After i segue a couple of times between 2 screen when the thread is busy. The thread don't perform every line.., The breakpoint just disappear when it has to return to the main thread. Can somebody please help me ? I

parallel_invoke same method in tbb

can I use parallel_invoke to execute the same function multiple times like I have function scan which traverse a string can I make the same multiple tasks operate on it.Yes, you can. Alternatively you can use a task_group: tbb::task_group g; g.run(fo

Stopping a for loop with a button

I am trying to stop a for loop that is initiated by pressing a button. The only problem I have found is that the application is literally non-responsive once the start button is pressed. How would I go about making the stop button? At the moment the

ClassCastException with JDialog and Thread

I have a JDialog with a thread in it. It sporadically gives me a ClassCastException when the dialog is created (which means I can have succesful ones with no exception), and I have no clue to where it should occur. Here's a snippet of my JDialog clas