Multithreading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).
0
votes
0answers
9 views
Multi threaded API calls problem
I have this API to control some hardware. The API is not very well documented, but I've been able to make do with what I have. It is a API for a RFID device, but also has LED's on it that are ...
2
votes
1answer
37 views
Best way to call future.get()
The following is a small part of some code I am working on
Which is better/faster/nicer?
1.
for (Future<Subscription> future : futures) {
try {
executorService.submit(new ...
0
votes
0answers
51 views
Generic Task Blocking Queue [closed]
A generic blocking queue has the following properties:
It is thread-safe.
It allows queuing and de-queuing of items of a certain type (T).
If a de-queue operation is performed and the ...
1
vote
2answers
48 views
Correct way to delete elements from a ConcurrentDictionary with a predicate
I have written a caching wrapper class for ConcurrentDictionary. Basically it has a timer that checks if items are expired and removes them. Since ConcurrentDictionary does not have RemoveAll method ...
2
votes
1answer
38 views
Proper way to cancel WebClient in BackgroundWorker
I have a WPF application that needs to get a XML document using a web request. The request is based on an id that the user enters. If the user enters a second id, before the first returns, I would ...
2
votes
1answer
37 views
Synchronization of remote files download
Preamble: it's a self-assigned and pure syntetic task to learn (and remember what I already knew) C# threads and synchronization and data structures.
The original question was here ...
3
votes
1answer
76 views
Dining Philosophers problem Solution with Java Reentrant Lock
I have implemented Dining Philosopher problem using ReentrantLock in java.
The goal of this program is
Every philosopher should follow the workflow of think,getchopsticks,eat,putchopsticks (No ...
1
vote
0answers
55 views
Need guidance using Tasks
I am doing multithreading using TPL Tasks first time. This is what i have done so far and I want to do it the right way. I will really appreciate if you could honor me with your expert advice.
I am ...
2
votes
1answer
65 views
Simple Freelock collection
I wrote simple lock-free collection class for saving items from multithreading code. I did it just for fun and experience. Can you check my code for potentially problems please?
public class ...
0
votes
2answers
102 views
ThreadPool implementation
The following code is a self-implementation of the static class ThreadPool in C#, only the QueueUserWorkItem (the simpler method), written to practice multithreading in the .NET environment and ...
3
votes
2answers
64 views
Moving from normal threads to ExecutorService thread pools in java
I had my original threading code which worked well, but since my tasks were shortlived, I decided to use thread pools through ExecutorService.
This was my original code
public class MyRun implements ...
2
votes
2answers
29 views
Refactoring an interruptable thread
I have a long-running task that processes an input file and then uploads it to a web server. The processing part can be interrupted (with cleanup) but the upload shouldn't be interruptable so that we ...
1
vote
0answers
22 views
Uses of barriers for one main thread controlling n threads
Referring to this post: http://stackoverflow.com/questions/16328828/one-thread-controlling-many-others
My problem (summarized): One main thread waits for connections, on accept() spawns a new thread ...
1
vote
1answer
32 views
Ensuring my program is thread safe
I have a class which is responsible for waiting until a message is added to a message list and then sending it off to get processed
withdrawMessages - waits for message. I wait a total of 2 minutes ...
2
votes
0answers
23 views
Fast popcount on Intel Xeon Phi
I'm implementing an ultra fast popcount on Intel Xeon® Phi®, as it's a performance hotspot of various bioinformatics software.
I've implemented five pieces of codes,
#if defined(__MIC__)
#include ...
2
votes
0answers
37 views
Monkey testing a SmartCard library
My definition of monkey testing is basically playing with a program in as if I was a monkey (press every button, unplug things, go in the wrong order..etc etc)
So I made a rather simple SmartCard ...
3
votes
1answer
106 views
Review of simple Java Actor library
How can I improve this code?
Also available from git://github.com/edescourtis/actor.git .
Actor.java
package com.benbria.actor;
public interface Actor<T> extends Runnable {
public ...
3
votes
2answers
56 views
Is this a scenario to use volatile instead of synchronized?
I want to know if using volatile in this scenario will give a better performance than using synchronization. Specifically for the paused and running instance variable in the SimulationManager class.
...
2
votes
1answer
84 views
parallel_for_each
I have constructed a simple implementation of a parallel loop.
#include <algorithm>
#include <thread>
#include "stdqueue.h"
namespace Wide {
namespace Concurrency {
...
2
votes
1answer
60 views
Java - Is this the correct implementation of a timer/timertask to destroy a process that overruns a defined time limit
I was wondering if this is the correct implementation of a times task to destroy a thread after it overruns a predefined time period:
it works by creating a getting the thread from ...
0
votes
1answer
62 views
Java concurrent Map of List
I need concurrent HashMap of List as value with following behavior:
count of read/write ops approximately equals
support add/remove values in lists
thread safe iterations over lists
After some ...
4
votes
2answers
174 views
Java HTTP Server and multi-threading optimization
I wrote an http server for the management of scores for users and levels.
It can returns the highest score per level.
It has a simple login with session-key.
What do you think could be improved in ...
2
votes
0answers
292 views
Lock-free multiple-consumer multiple-producer queue
The code below implements an intrusive lock-free queue that supports multiple concurrent producers and consumers.
Some features:
Producers and consumers work on separate ends of the queue most of ...
1
vote
0answers
34 views
Communication with GARMIN throught WEB (Java Socket Programming Code Review)
I am developing a WEB based GPS system and one of its functionallity is to be able to send messages and routes to GARMIN devices.
I have never been using sockets before and for some (obvious) reason ...
0
votes
1answer
46 views
Does refactoring a while loop increase CPU usage
While upgrading our code base to take advantage of new features in .Net 4.5, I'm trying to refactor our take of the classic Producer/Consumer algorithm, but I'm concerned my refactoring is going to ...
0
votes
1answer
92 views
Multi Threaded Error Logger
I am trying to design a class that will log errors to a text file, the application is using threads heavily so it may be that 2 errors that need to be written at the same time. I know there are 3rd ...
3
votes
1answer
113 views
Multi threaded circular buffer
I should write a circular buffer with multithread write and single read ability. Here is my solution:
public class RingBuffer<E> extends AbstractList<E> implements RandomAccess {
...
1
vote
1answer
186 views
How to update my Swing JTable dynamically. MVC Pattern
I have created a program using a version of MVC architecture. The purpose of the code is to scrape the h1 titles of a list of webpages and to return the results to a JTable.
So far I have the ...
1
vote
1answer
91 views
creating dynamic threads
First, I want to say that this code works, but I want to make sure this is the right way of doing it. I am writing this for a SMS text API that loops through each phone number. I sometimes gets hung ...
3
votes
1answer
72 views
Implementation of ordered lock pattern
Below is attempt to catch potential deadlocks at runtime in C#. Basically this class allows user to acquire locks in a pre-defined order only. I ran some basic tests and it appears to work. Please ...
0
votes
0answers
55 views
Haskell network connection graceful handler
Just trying to work out some simple graceful connection handling code in Haskell to get my head around some of the IO/Networking/Threading stuff, some tips where I'm doing things poorly would be ...
1
vote
2answers
83 views
Multi-threaded Winforms Conventions for Main()
I'm trying to find a good pattern for new applications (and for refactoring old ones).
Maybe it's just me, but I dislike spawning my main logic thread from inside my main form thread (so far I always ...
0
votes
1answer
100 views
Asynchronous version of AutoResetEvent
This is my second attempt to create asynchronous version of AutoResetEvent.
At first I tried to make it completely lock-less, but it turned out to be impossible.
This implementation contains a lock ...
3
votes
1answer
193 views
Java thread safety and caching techniques
This is my first Java multi-threading code. It is part of an Android application that is a client to a webpage that serves books. Each page of the book is in a separate PDF, and the Book class ...
0
votes
0answers
60 views
Finding Potential Thread Safety issues and Race conditions in my Multithreading Code
I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using ...
1
vote
1answer
51 views
Log and Count the exception in a Single method
I am tring to count the number of exceptions happening and log those exceptions as well. So what I did is, I created one method addException in which I am counting all the exceptions.
addException ...
1
vote
1answer
86 views
Looping through the ResultSet efficiently and the add the values for columns in List<String>
I am working on a multithreaded project in which each thread will randomly find columns for that table and I will be using those columns in my SELECT sql query and then I will be executing that SELECT ...
1
vote
1answer
177 views
Producer/Consumer with some limitations
The code realizes producer/consumer problem with multiple producers and consumers. Have this code any potential deadlock or races?
//RandomDataProvider.cs
namespace MyNamespace.Core
{
using ...
2
votes
4answers
162 views
Designing a better logger class
Could you please critisize the logger class below? Can it be used in a multi threaded web environment? If not how can I improve it? Is there anything wrong with locking in WriteToLog method or ...
3
votes
1answer
106 views
Thread Safety issues in the multithreading code
I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using ...
3
votes
1answer
1k views
Java multithreaded file server and client. Emulate TCP over UDP
This is for homework.
My task was similar to my last assignment but this time I had to do it with UDP instead of TCP. This basically means I had to emulate TCP over UDP.
Multithreading was an ...
1
vote
2answers
122 views
Does my main class have too much code?
For some reason i have the feeling that i should put all of my thread starts and joins in a for loop just to reduce the amount of code. I dunno if that will hurt readability on this class? Also is it ...
2
votes
1answer
149 views
Lock free MPMC Ring buffer implementation in C
I have written a lock free MPMC FIFO in C based on a ring buffer. It uses gcc's atomic built-ins to achieve thread safety. The queue is designed to return -1 if it's full on enqueue or empty on ...
1
vote
2answers
71 views
Correct implementation for background task execution in web application?
I have a simple servlet which merely serves some cached data back to the user. I also have a background thread which runs at fixed intervals to refresh the cached data. Is this a reasonable ...
2
votes
0answers
47 views
Is this a correct way to handle a thread which uses a socket?
I am building an app for android to control VLC (mediaplayer) that runs on my computer.
Atm it's just a prototype and it works but I was wondering if I am correctly managing my HandlerThread and ...
3
votes
2answers
162 views
Multi-threaded sort
I wanted to write a multi-threaded sort, unfortunately I don't know much about threads, especially in C++11. I managed to make something work, but I would be highly surprised if it was the best way to ...
4
votes
1answer
51 views
Timing single operation to not be repeated for a fixed time
Sometimes "a" service does not respond and so we need to restart it. Usually it's a glitch in the network. We can have like 100 calls at the same time so the service cannot be restarted for 100 ...
2
votes
1answer
129 views
Simple ThreadSafe Log Class
For the m_listeners BlockingCollection<>, I know it's a bit hacky right now, but I'm not sure what to use instead (List<>, Dictionary<>, something else?). I want to be able to add/remove ...
1
vote
1answer
44 views
Alternative to using sleep() to avoid a race condition in PyQt
I have a situation where I would like to use a single QThread to run two (or more) separate methods at different times. For example, I would like the QThread to run play() sometimes, and when I am ...
0
votes
3answers
65 views
How to correctly get a IDisposeable when you need to lock the factory?
If I need to create a IDisposeable object from a factory, but if the factory object is not thread safe and requires me to lock on it is this the correct pattern to use?
public void ...
