Multithreading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).

learn more… | top users | synonyms (2)

3
votes
0answers
32 views

Is the way I used threading in Python correct?

I'm learning how to use Python with the Raspberry Pi. I successfully followed the tutorial for how to have a Python script run on the Pi to check for new email and turn on a LED if any new messages ...
6
votes
0answers
69 views

A simple Thread Pool

A very simple Thread pool: Any work added to the pool will be executed. The destructor will wait for all work to be finished before letting the threads stop. We then join all threads before letting ...
7
votes
3answers
119 views

Parallel sieve of Eratosthenes, version 2

This question is a revision of Parallel sieve of Eratosthenes. The goal is to implement a sieve of Eratosthenes with parallel strikes out from the boolean array. I tried to fix the data races and all ...
4
votes
1answer
68 views

Pre-Java 5 threads

I would like to revise the fundamentals of Java threads on before-Java 5, so that I can understand improvements in Java 5 and beyond. I started off with a custom collection and need help on: Things ...
19
votes
5answers
959 views

Parallel sieve of Eratosthenes

For the first time, I tried to use threads by myself in order to implement a parallel sieve of Eratosthenes. The trick is that each time a prime is found, a thread is spawned to eliminate all the ...
4
votes
1answer
73 views

A simple little Python web crawler

The crawler is in need of a mechanism that will dispatch threads based on network latency and system load. How does one keep track of network latency in Python without using system tools like ping? ...
2
votes
0answers
34 views

Optimizing a thread library

Please give thoughts and optimization tips on my thread library. Update 1 : I have renamed the different method types. ...
7
votes
2answers
336 views

Returning the result of whichever method finishes first

Consider a method (let's call it IsPrimeHybrid) which calls at least two methods (let's call them IsPrimeNaive and ...
3
votes
1answer
55 views

Lockfree ThreadPool implementation

How could this template class ThreadPool be improved? I use Boost queue to keep std::function's numbers from ...
5
votes
1answer
41 views

CountdownLatch: Is this thread-safe?

I am trying to learn how to write correct lock-free code. I've written this class out of exercise for a synchronization construct to be used across multiple threads. The intent is to have worker ...
11
votes
3answers
227 views

Extending ThreadPoolExecutor

I have implemented a ThreadPoolExecutor that will run a Consumer<T> only on elements not already consumed. This code uses ...
4
votes
2answers
63 views

Same function, variable parameters and types with lambda

In my current project, I find myself using Dispatcher.Invoke a lot. Before each call I test if the current dispatcher is the right one. I want to write a wrapper ...
4
votes
2answers
97 views

How many squares can you see?

With a positive outlook, I posted this challenge at Programming Puzzles & Code Golf. I tried to come up with my own solution to the challenge which is as follows: The output is displayed (not ...
9
votes
2answers
105 views

Is this use of a resource based on session ids thread safe?

Let me first describe the expected behavior of the code below: There will be one static SessionManager accessed by many threads. Multiple calls to ...
9
votes
4answers
272 views

Tic-Tac-Toe feedback requested

I just started learning coding about 4 months ago, I think Tic-tac-toe was the first application that I've ever written in C# not counting the mandatory "Hello, World!". So for me, I really wanted ...
8
votes
1answer
169 views

NSInvocation Implementation

I'm using NSInvocation as a choke point in my app to help manage threading and reduce the amount of redundant code. The purpose of this class is to pass arguments ...
7
votes
1answer
78 views

Lockless Queue Multiple-Reader Singler-Writer in C++

I wrote a lockless queue for sending small objects from a single thread to a random worker thread. Assumptions: x86/x86_64 compiled with GCC one thread may Write(), multiple threads may Read() ...
5
votes
2answers
192 views

Using an AsyncTask to populate a ListView in a Fragment From a SQLite table

This is the first time that I have played around with AsyncTask in Android and I wanted to make sure I'm using it correctly. The idea is I'm grabbing all the rows from a table in the database using ...
9
votes
5answers
232 views

Inner class calling outer class method

I created a console program that tests report results from JasperReport. It retrieves the list of reports, splits it, and passes each sublist to a new thread. Each thread executes its own reports and ...
6
votes
1answer
102 views

Simple asynchronous operation implementation

Could you please see if they are no bugs in this implementation? I am especially interested in knowing if there could be here any multithreading problems (such as race conditions). It is written in ...
6
votes
1answer
37 views

Handling packets and peers in a reliable UDP library

I am refining my reliable UDP library, its at its 3rd iteration now. It is quiet a bit multi-threaded with almost all major operations having dedicated threads. I need your opinion on the following ...
2
votes
0answers
88 views

Is my threading design okay or not?

I am new to threading and I am a junior developer, so I guess there are many mistakes. My scenario is this: look into the database if there are data which should be sent add the data to the queue ...
6
votes
1answer
90 views

ReaderWriter Synchronization

This code uses a ReaderWriterLockSlim to store data (on a disk or wherever), so that only one thread can write and many threads can read. All writers should be ...
4
votes
2answers
131 views

Using threads to find max in array

I really do not have access to anyone, outside of professors, that is highly knowledgeable about Java so I figured I would post my stuff here to further my knowledge and improve my coding. This is ...
4
votes
1answer
54 views

Review/improve thread test mutex implementation

I am trying to make a thread test in which 4 threads are all trying to set a bool. Only one should be allowed to set it. After the first thread has set the bool(m_isRunning) to true, no other threads ...
1
vote
0answers
18 views

Safely resetting an outside service that handles requests from multiple threads

I have a program that processes Microsoft Office documents (and other kinds, but primarily Office). I am replacing one purchased product that performs this processing with a new one. This new product ...
7
votes
1answer
163 views

Cache<Long, BlockingDeque<Peer>> combined with Striped<ReadWriteLock>: is it thread-safe

I've implemented PeersContainer class with all operations that I need. I need something like multimap in concurrent environment, moreover I need remove entities ...
5
votes
1answer
80 views

Sending n requests in one time

I need to test my new functionality by sending about 100 requests in one time. ...
4
votes
2answers
136 views

Producer/Consumer implementation

I am using Netty embedded within Grails to process and display incoming SNMP messages. Since Netty 4 doesn't come with a built-in ChannelExecutionHandler I had to ...
4
votes
2answers
226 views

A TaskScheduler that always run tasks in a specific thread

The following is an TaskScheduler that always run tasks in a thread it maintains. When created, a name of the thread was specified. Once you schedule the first ...
4
votes
2answers
125 views

Chaining Tasks with async/await

I've been trying to learn how to use the TPL for quite some time now. Basically I'm trying to fire off a group of Tasks, wait for them to complete and then fire off another group of tasks, waiting for ...
1
vote
2answers
67 views

Progress bar in a multi-thread application

I am developing a WPF application and was practising around the multi-threading. I have write the following code ...
3
votes
2answers
105 views

In-memory cache implementation revisited

As a follow-up on my earlier question, here is the new implementation. The major change is now that the base class just deals in ICacheValue values which are ...
5
votes
1answer
65 views

Lock-free producer/consumer implementation

I know of BlockingCollection in .net, but this is rather for my understanding of the pattern. Is this implementation correct ? Consumer ...
11
votes
3answers
122 views

Long running, frequent async advice?

A user must query a large database for information repeatedly. This query may take up to ~7 seconds. This must be done asynchronously. Only one query will be running at a time. I did not create a ...
3
votes
1answer
155 views

Run a TCP server listening for incoming messages

I've written the following code, but I need some review on design style. I want to develop a library/module and expose an API to client programs. How do I do that? The code just runs a TCP server ...
5
votes
3answers
273 views

Client Sends XML, Server Parses XML, Queues Up and Executes Commands

I recently had a Java interview where I was asked to write a client-server application. I don't code primarily in Java, but with my preliminary Java knowledge, I thought I built a reasonable working ...
2
votes
1answer
109 views

Filter email with JavaMail

I'm trying to develop code to filter my e-mail with JavaMail, but I doubt it's the best way of doing this. And I want to collect all messages without attachment. ...
7
votes
1answer
130 views

Creating a thread for file transfer

I am creating an application in Java that runs at scheduled intervals and it transfer files from one server to another server. For SFTP I'm using ...
4
votes
1answer
74 views

Simple Multithread Timer

This is a very basic timer that can support multithreading with std::thread and std::chrono. The timer has the classic ...
5
votes
2answers
292 views

Simple thread pool in C++

I wrote a simple thread pool, which works pretty well. I would like to see your review of it. One important feature that I needed in the pool is the ability to wait until all the tasks that I sent to ...
4
votes
2answers
222 views

Portable periodic/one-shot timer implementation

I have implemented a class that provides portable one-shot or periodic timers. The API provides a way to schedule one or more timer callbacks to fire some number of milliseconds in the future, and ...
1
vote
2answers
94 views

Is that correct example of unsafe publication in java? [closed]

There are many examples of unsafe publication on the web. But I cannot find a complete program for reproducing it. I wrote an example but I do not sure whether it correct or not. And in case of ...
11
votes
3answers
216 views

Pi Benchmarking in C

I wrote the following program to calculate n digits of Pi (where n could be anything, like 10M) in order to benchmark the CPU and it works perfectly (without OpenMP): ...
20
votes
3answers
1k views

Java method - levels of abstraction

In his Clean Code book, Robert C. Martin states that functions should do only one thing and one should not mix different levels of abstraction. So I started wondering whether the code below meets ...
3
votes
1answer
140 views

How to avoid GSON deserialization if I am aware of error response from the server?

I am working on a project in which I am making a call to one of my servers using RestTemplate which is running a restful service and getting the response back from ...
3
votes
1answer
102 views

How to make builder pattern thread safe in the multithreading environment?

I am working on a project in which I need to have synchronous and asynchronous method of my java client. Some customer will call synchronous and some customer will call asynchronous method of my java ...
3
votes
1answer
42 views

Invoke only by a single thread

I wrote a simple class in Python, which controls code invocation, in a multi-threaded environment, with the following logic: The class' main method, named ...
4
votes
2answers
70 views

Double checked locking 101

I've found a peace of code I've wrote not long ago. It is used to fetch some dictinary from DB table only once and then return it to requestors. Seems like I tryed to implement double-checked locking ...
3
votes
3answers
401 views

Decrease CPU usage in while loop

I've a application which runs with two threads. The main thread runs in one infinity-while-loop: ...