Multithreading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).
2
votes
0answers
34 views
Polling multiple servers
I have an application which polls a bunch of servers every few minutes. To do this, it spawns one thread per server to poll (15 servers) and writes back the data to an object:
import requests
import ...
2
votes
1answer
109 views
Searching through a huge set with threads
I wrote a class that finds values in a huge search volume. I have a pretty strong feeling that my code is not good and would like to get your opinion on it. My experience with C++11 threading is very ...
3
votes
1answer
79 views
Volatile boolean to prevent Deadlock (Is Lock better than Volatile)
I wrote this code to overcome the deadlock condition described in this Oracle Tutorial
http://docs.oracle.com/javase/tutorial/essential/concurrency/deadlock.html
Summary of Problem:Alphonse and Gary ...
2
votes
1answer
85 views
Threading in Java
I wrote this small project to practice threading in Java. At first, I planned to do it like this. But later, someone pointed me to Executor. Then, I found this tutorial and followed it through. Here ...
1
vote
0answers
30 views
1 producer, n consumer with QThread
I am new to c++ and to threading too, so sorry if my code is bad. I'm here to getting it better and learning.
Any kind of advice (both on c++ style, on Qt usage, or on threading handling) is ...
2
votes
0answers
74 views
Proper cleanup in multithreaded client/server code
For a university project I'm trying to build a system that has a general architecture of:
Client app <=====> Client library < - - > Server library <=====> Server app
I'm trying to make the ...
0
votes
1answer
141 views
How to further improve this Ramer-Douglas-Peucker algorithm in C#
Ramer-Douglas-Peucker is a great algorithm for reducing the number of samples in a given trace, and also for keeping its general shape (as much as he can).
I have a trace with 32.000.000 samples, and ...
1
vote
1answer
27 views
Efficient way of printing a range of numbers using configurable worker threads
I have written a code to print a range of numbers using multi-threaded programming , the code takes in the number of threads to spawn as input .The code is working fine and giving the expected results ...
0
votes
0answers
59 views
Improving class for parallelising parts of main codebase
This is a class I wrote for parallelising certain parts of my main codebase. How could this code be improved in terms of making it shorter, more secure, and more efficient?
using System;
using ...
1
vote
2answers
67 views
Does this Actor implementation has synchronization problems?
As a part of a job test, I wrote following implementation of the Actor execution model:
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Executor;
public abstract ...
2
votes
1answer
74 views
Generating random numbers in multiple threads
I'm trying to learn how to use threads to generate lots of random numbers. In particular, I'd like know:
Is the following code thread safe? (I think the histogram class is the only one that requires ...
3
votes
0answers
146 views
C# class to encapsulate and manage multiple background web crawlers
I need to crawl web contents from some websites and then do some processing. Note that this is a small application, so the dataset is relatively small (need to crawl about 30,000 pages every time, ...
4
votes
0answers
112 views
Multithreaded task-scheduler (C++11)
This is (supposedly) a multi-threaded scheduler for one-time and/or repeating tasks. The tasks are simple std::function<void()> objects. I built it to be a crucial part of a larger project I'm ...
0
votes
1answer
98 views
Stuck with Multi-Client Chat Application
I'm trying to make a MultiClient Chat Application in which the chat is implemented in the client window. I've tried server and client code for the same. I've got two problems:
A. I believe the code ...
2
votes
1answer
87 views
Is this actually thread safe?
I wrote this class to ensure that anything done in any of my worker threads can be displayed on the GUI via events, but i ran into non-thread-safe problems.
This class should take a action with zero ...
1
vote
2answers
86 views
Loading data async with queue. Proper write only locking and scheduling
I have to store and return data on multitasking requests. If data is missing, I schedule loading and return null. I'm using some nubie scheduling by saving current jobs in a list. Also I need data ...
1
vote
0answers
50 views
An implementation of parallel workers in Ruby
Much in the spirit of this question, I have implemented a simple class for parallel workers and wanted to get some feedback on it. Can I make the code even more concise or readable? Are there any ...
0
votes
2answers
113 views
Looking to improve mutex implementation
Overarching Problem
I am creating a threadsafe Queue that will act as a shared buffer between two threads for a game I am developing. I need it to be threadsafe so that one thread can throw messages ...
0
votes
0answers
50 views
Simple input lag test
This is my first post on stackexchange. So I am somewhat inexperienced in programming, but I take an interest in C and C++. Anyway, I have created a simple program that should be able to test for ...
1
vote
0answers
163 views
Asynchronous Server Sockets - Thread-Safety/Performance (MMO Gaming)
I'm writing this game server for my small 2D MMO game.
So here are my questions:
What do you think about the Thread-Safety of the code?
Please explain how can it be made thread-safe / show example/ ...
1
vote
1answer
110 views
Multi-threaded socket client for Scrolls
https://github.com/david-torres/ScrollsSocketClient
from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA
from base64 import b64encode
from threading import Thread
from Queue import ...
0
votes
1answer
114 views
Multi threaded application to send large no of emails
I need to build a application which sends a lot of emails. These emails are based on a table. Basic idea is, I grab a bunch of records from database. Create MailMessage (System.Net.Mail) and send it. ...
1
vote
1answer
70 views
Feedback on a Python 'sleeping barber' program
I recently came across the Sleeping Barber problem and found out that it is a good place to start learning how to use threads properly.
I don't have too much experience with threads and want to ...
-1
votes
1answer
82 views
Log4Net Wrapper with some error potential [closed]
Some time ago, I found the following log4net wrapper here
But I think it is errorprone (in case of threading, could there be deadlocks?)
and the public interface seems to be too wide.
What to do ...
2
votes
1answer
76 views
Is this the best message delay algorithm?
In my application I am attempting to queue outgoing messages by the following rules
By default they should be sent no less than messageDelay apart
Some messages can be sent immediately, completely ...
2
votes
1answer
67 views
Review: custom, simple cache with load timeout and expiry; thread safety, tests: can I do better?
The following is a code from one of my projects which implements a loading cache with timeout and expiry. The associated tests are here (mixed with a good number of argument sanity checks tests). I ...
0
votes
1answer
138 views
Using Barrier to Implement Go's Wait Group
I have implemented a WaitGroup class to simulate WaitGroup in Go lang. Then I've found that I can use Barrier in a different manner, to achieve the same thing. My WaitGroup has some additional ...
1
vote
4answers
153 views
Simple multi-threading class: Does anybody spot potential lock-based concurrency issues?
Trying to write a multi-threaded utility that logs some audit trails to the DB every 30 minutes, or whenever my storage data structure (a list in this case) exceeds a certain limit. The code works ...
2
votes
2answers
102 views
Criticize my threaded image downloader
I'm going to be working on a much larger version of this program and I just wanted to see if there was anything I should change in my style of coding before I made anything larger.
If it wasn't ...
1
vote
2answers
664 views
Reading output from multiple threads and writing to a file
There are 10 threads and I have 15 tasks. Now I have submitted all these tasks to these threads. I need to write all these threads output to a file which I was not successful.
I am getting output by ...
2
votes
2answers
53 views
Perl mutiple children creation
My program will fork, launching $n children. When a child finishes, the parent will launch a new one, if we have more to launch.
#!/usr/bin/perl
use strict;
use warnings;
use POSIX ":sys_wait_h";
...
2
votes
0answers
226 views
Reusing thread and UdpClient for sending and receiving on same port
The working and functional code below is a simplification of a real test application I've written. It acts as a client which asynchronously sends UDP data from a local endpoint and listens for an ...
0
votes
0answers
28 views
Create multithread DAO helper instance
I am using struts 1.3 action layer with hibernate. I am accessing through HeperFactory patten to create helper instance to access DAO layer.
The helper factory seems to be Singleton but thread safe. ...
1
vote
1answer
48 views
Review of concurrent php logic for a web spider class
I wrote a web spider that I would like to download and parse pages concurrently. Here is what I am trying to achieve:
instantiate a new instance of the class with the $startURL as the constructor
...
0
votes
0answers
14 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
60 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 ...
1
vote
0answers
172 views
Generic Task Blocking Queue
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
276 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
104 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
52 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
503 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 ...
2
votes
1answer
89 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
70 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
447 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
259 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
38 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
25 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
38 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 ...
3
votes
0answers
58 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 ...
4
votes
1answer
62 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 ...