Multithreading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).
0
votes
1answer
14 views
Cross Thread Access to Object in ViewModel
This is a fairly straight forward question. I have a C# WPF MVVM application that call a C++ DLL to do some compilation/crunching. To update the UI C# application for progress updates I am using ...
4
votes
2answers
273 views
What are the best practices with multithreading in C#?
For a while I have been interested in seeing if some tasks work well when split across multiple threads.
On the one project I have been busy with I have been creating a lot of small utility apps, to ...
3
votes
1answer
46 views
Platform independant thread pool v4
This is a continuation of this question.
Following the previous advise, the thread pool now can handle almost all types of input, except for one key form, where the function/functor requires one of ...
4
votes
2answers
215 views
Creating a cache manager
I am purely new to C++ memory management. Am I on the right path, or should I employ a different design strategy or a different memory manager policy (such as ...
3
votes
2answers
53 views
Function object passing for a task scheduler
Here is my full implementation of a generic Functor-like class:
...
4
votes
0answers
180 views
Multithreaded file downloader using threading and signals
This is my first attempt to write a multithreaded application that downloads files from internet. I am looking for improvement in code, logic and better strategy for implementation.
Please ignore the ...
2
votes
2answers
47 views
Platform independant thread pool v2
This is a continuation of this question, v3 can be found here
Taking into account the advise given by Loki, an implementation of the threadpool using a ...
7
votes
1answer
64 views
Platform independant thread pool
v2 of this question is here and v3 is here
To get a better understanding of C++11/C++14, I thought I would develop a thread pool, even if it has been done to death!
The only dependency outside of ...
9
votes
1answer
160 views
Thread-Safe Integer Sequence
I would like to give an Integer to whatever demands it. For that I use the following code
...
1
vote
0answers
15 views
Mutualising multi-threaded calls to EJB from Servlet
I have a Servlet that makes an EJB call to a backing server which takes about a second to return some data that changes reasonably regularly.
I can't cache the data on the Servlet-side, so I have ...
6
votes
2answers
593 views
A simple semaphore in Java
It is a simple semaphore in Java. Although it passes all their tests with flying colors, I'm still not sure it's correct.
For example, the last thing I wasn't sure about was ...
1
vote
0answers
30 views
Moonshot & `Thread.Abort` - dealing with the fallout
Recently, I encountered an anomaly in the manner by which a worker thread was terminated. It prompted me to do some searching and I realized that I was constructing thread code in a haphazard manner. ...
4
votes
2answers
121 views
Concurrent blocking Tasks in a BackgroundWorker
I'm using a StaTaskScheduler (TPL extension) to open some web browser windows simultaneously and navigate to different sites (using WaitN, but it might as well just be a ...
4
votes
1answer
34 views
Scalability of C server implementation based on pthreads
I am wondering about the feasibility of the following basic implementation of a server and how well it would scale. I know that large-scale, distributed servers should probably be written in a ...
6
votes
4answers
88 views
Calculation of e performance issue
Can you give me some idea how to optimize the switch statements, maybe a for or do while ...
1
vote
1answer
95 views
Thread-safe callback registration and invocation in C++11
I need your help in reviewing the following code. My main concern is dead-lock, but there might also be other issues.
The EventGenerator object is owned by a ...
1
vote
1answer
19 views
Proxy using socket, doubts on multithreading and connection closing
I'm trying to make a simple proxy server in Python using the socket library, mostly to understand how it works. I'm a noob both at programming and networking, so please be nice if my questions are ...
0
votes
0answers
7 views
In which object should I implement wait()/notify()? [migrated]
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 ...
3
votes
0answers
84 views
Concurrent queue
I recently wrote a concurrent, mutex-less (but not lockfree) queue and wanted to know if it is actually correct, and if there are any particular improvements I could make:
...
9
votes
2answers
323 views
Using synchronized blocks and volatile variables to ask a Java thread to terminate gracefully
Edit: Just to clarify, this isn't my original code, I've simplified it to make it smaller/easier to understand what I'm trying to do.
It's my first time working with threads in Java, and I was ...
3
votes
2answers
180 views
Slow data-processing and inefficient memory usage in .NET containers
I am writing a text classifier and in order to do so I need TF/IDF values per every word of my signle text. Then I need to use the cosine similarity:
\$similarity = cos(\theta) = \dfrac{A \cdot ...
9
votes
1answer
120 views
My first multi threading class
I've thrown everything I can at this, and I can't get it to lock or crash. My hope is that I have applied the principles correctly. I write client apps in JavaScript, and this is only the 3rd .NET ...
2
votes
1answer
78 views
Threaded pipeline
I have a threaded pipeline with single producers and (possible) multiple consumers. A producer might wait or not, depending on the policy provided. A problem here is valgrind (helgrind) is reporting a ...
4
votes
5answers
499 views
Circular queue implementation
Implemented simple thread safe circular queue. Looking for code review, optimizations and best practices.
...
1
vote
1answer
72 views
Multi threading in ASP.Net to increase performance of processing data from entity framework using anonymous types
Intro
I am trying to populate a Multi-column Combo-box with a large amount of records.Depending on the selection the user has taken there can be 1 - 50000 items in the Combo-box (I may not display ...
2
votes
1answer
98 views
Optimize a parallelized program to optimize train schedules
This loops through a vector of vector of A and adds a smaller array to a bigger one at a specified position+random shift. Then it is checked if it is a better solution, and if yes, it is stored, else ...
2
votes
0answers
58 views
Having functions run on different threads
I would like to know if there is a more optimal/efficient way of having some of my functions run on a different thread. When a user clicks a button, the program will either:
...
5
votes
3answers
259 views
Multiple background tasks
This is taken from my post at Stack Overflow here.
I need your help to review my code for improvement and best practice.
...
3
votes
1answer
54 views
Sequential Thread Execution using wait() and notifyAll()
Problem Statement:
T1, T2 to Tn threads prints numbers up to N such that each threads
prints number in circular sequential fashion. T1 prints 1, T2 prints
2, T3 prints 3 and T1 prints 4 again ...
6
votes
3answers
148 views
Is my below code thread safe w.r.t all the main application threads should get consistent data?
I am working on a project in which I construct a url with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
4
votes
2answers
38 views
Download URL from clipboard
This is a Python script I made to download a URL from the clipboard.
When a new URL is copied to a clipboard it adds the URL to a download queue, then on a separate thread it downloads the URL to a ...
3
votes
2answers
72 views
Asynchronous Pattern
I have an n-tier solution which consist of DAL,BL and a ASP.net WebAPI project. I'm new with Asynchronous Pattern and I'm trying to add it to my Framework. Am I doing asynchronous pattern correctly? ...
7
votes
2answers
107 views
How to make sure all the threads are getting consistent data without performance impacts?
I am working on a project in which I construct a url with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
0
votes
2answers
88 views
Continually process results of multi-thread worker [closed]
Let's say we've got some SQL queries and want to display the results. Processing takes some time, so I do it multi-threaded.
The following works quite well for me. I reduced the code to the important ...
3
votes
2answers
71 views
Thread-safe queue
I need a thread-safe C++ queue. This is what I have in my project, which is mostly based on code I've found on Stack Overflow. How good is it? Can you make it better? Can you suggest better ...
6
votes
2answers
128 views
Implement HTTP Server with persistent connection
I am trying to implement a HTTP Server in Java, I want the server to use a persistent connection per thread for request and response. After some research on Google, this is how my program looks like. ...
2
votes
0answers
32 views
Writing a log file with threads
Here are all the threads write the log file. I want to know if the below script is fine, if it needs any modifications, and whether I am utilising threads properly to execute this code fast.
...
4
votes
3answers
125 views
Usage of AtomicBoolean
I would like to find out if following usage of an AtomicBoolean as a flag variable is correct and good for a multi-threaded application. It is expected that data is ...
6
votes
1answer
127 views
Program to shutdown computer after a certain time
I'm trying to make a program that will shutdown my computer after a certain time that I will input via GUI. I'm wondering if I did it the correct way.
Also, will this slow down my computer while it ...
2
votes
1answer
54 views
Inline script routine for Open Sesame experiment
I am new to Python as well as threading and had to build an inline script routine for the use within a Open Sesame Experiment. The Routine should open a program, play tones and catch reaction times. ...
4
votes
1answer
132 views
Writing to file in a thread safe manner
I'm writing Stringbuilder to file asynchronously. This code takes control of a file, writes a stream to it and releases it. It deals with requests from asynchronous operations, which may come in at ...
4
votes
1answer
78 views
Single consumer and single producer lock-free circular buffer
I'm pretty new to multithreading. The code below is a simple implementation of a single consumer/single producer circular buffer that does not use any locking, that I wrote for fun.
The question ...
1
vote
0answers
63 views
Reviewing legacy multithreaded code [closed]
Here a paste the code of a legacy unit i maintain, my comments after the code.
...
0
votes
0answers
32 views
Uploading a .csv to a NoSQL cluster - batch beat out consumer/producer
I was tasked with making a program that uploads a .csv to a NoSQL cluster. We were doing 2-5 gig files, and it was taking 4-8 hours. Well when we hit 17 gig files that was just to slow.
When I ...
7
votes
1answer
242 views
Implementation of Parallel.ForEach for .NET 3.5
Because the TPL backport not only contains Parallel.* but also PLINQ, concurrent collections, etc, I will try to use this one.
Just for fun, I profiled both the TPL implementation and my own, in the ...
5
votes
1answer
71 views
Using CountDownLatch for blocking the reads if writes are happening
I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three maps.
Requirements:
Reads block until all three maps have been set for the first ...
3
votes
1answer
37 views
Should I worry about spurious wakeups in Java's BlockingQueue.take()?
I wrote this code where I trap InterruptedException's in a blocking queue and try again to consume from the same queue thinking of Spurious wakeups. I don't know if ...
4
votes
1answer
86 views
How to avoid reads before initialization is complete and return updated set of maps value?
This is a follow on to: How to prevent reads before initialization is complete?
I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three ...
6
votes
2answers
398 views
How to prevent reads before initialization is complete?
I am trying to implement lock by which I don't want to have reads from happening whenever I am doing a write.
Below is my ClientData class in which I am using ...
12
votes
2answers
205 views
Can I make the thread safe case faster?
The code below is part of one of my projects called largetext, which actually stemmed from a question on StackOverflow.
The goal is to provide access to a very large text file as a ...