Questions tagged [multithreading]

Use this tag when the program performs its work using multiple concurrent threads of execution.

Filter by
Sorted by
Tagged with
1 vote
1 answer
410 views

Multithreaded batching class

I need to write a class to batch Order objects from 3 calling components running on 3 separate threads. The 3 calling components will call the ...
user avatar
4 votes
2 answers
358 views

Accessing limited resources with Pthreads

I'm a Pthreads newbie and I've been giving myself a challenge: I want to have a resource that multiple threads can access at the same time as read. However, if a thread wants to write, then this need ...
user avatar
8 votes
1 answer
5k views

Multithreading algorithm for high performance parallel computing and Producer-Consumer queue using POSIX threads

The following is the producer-consumer algorithm for a piece of software that I'm upgrading to take advantage of multi-core processing. The intended platform is some flavor of Linux running on an EC2 ...
Matt Munson's user avatar
2 votes
2 answers
5k views

TCP/IP sending and receiving threads

It's my first stab at TCP/IP and honestly I'm just starting out on C# also, so any comments on the design, method, etc are more than welcome. Basically I wanted to create a listening thread and ...
melaos's user avatar
  • 121
2 votes
1 answer
3k views

Is this a safe/correct way to make a python LogHandler asynchronous?

I'm using some slow-ish emit() methods in Python (2.7) logging (email, http POST, etc.) and having them done synchronously in the calling thread is delaying web requests. I put together this function ...
Ry4an Brase's user avatar
4 votes
4 answers
2k views

Thread-safety and delegates with generated numbers

In the main class, loops generate numbers (0~100), and when its generated number is > 20, its value is passed to the thread where it simulates some work with this number. Meanwhile, while this number ...
BreteP's user avatar
  • 41
3 votes
1 answer
1k views

Resource locker in Qt

The idea is to lock resources in C# or Java using Qt: lock(obj){/*process with locked obj*/}` Now I see the problem with deleting ...
Lol4t0's user avatar
  • 224
4 votes
1 answer
992 views

Single word CAS tagged pointer for algorithms susceptible to the ABA problem

I've been looking for a solution to the ABA problem for a lock-free stack. Searching the Web revealed patented and complicated hazard pointers and tagged pointers using double compare-and-swap (DCAS, ...
igrek's user avatar
  • 41
5 votes
2 answers
1k views

Optimizing a Fire and Forget page tracker

I have a bit of code that came from Egg Head Cafe a long while ago and it's been working great. But I ran the entire site through Redgate's Profiler. and it came up as the biggest hot spot in my code. ...
Tim Meers's user avatar
  • 249
1 vote
1 answer
4k views

Properly creating a Task to poll and dispatch child tasks with cancellation for each

I'm creating a dispatcher class - which is itself a long running task which can be cancelled at anytime by the user. This Task will poll the database to see if there is any work that needs to be done,...
Matthew M.'s user avatar
2 votes
2 answers
7k views

Passing a member function in pthread_create

I have to use a C++ member function in pthread_create. Also, the member function needs to be able to get the argument. So, I have implemented a launcher function, which with help of a launcher object ...
Medicine's user avatar
  • 443
5 votes
2 answers
28k views

Cash-withdrawal from an ATM

I'm seeking review comments (design, performance, etc.) based on the problem statement: Write a CashWithDrawal function from an ATM which based on user specified amount dispenses bank notes. ...
JavaGreenhorn's user avatar
1 vote
1 answer
176 views

Optionally running some code on a background thread

Is this a good method to optionally run some code on a background thread depending on a configuration setting? This will primarily be called from an ASP.NET front-end (although others are possible) ...
DanP's user avatar
  • 113
3 votes
3 answers
16k views

Helper methods for working with the WPF Dispatcher

I've written the following small helper class for use in my WPF applications. It comes up from time to time that I need to display message boxes, or otherwise interact with the UI from a non UI thread....
Nathanael's user avatar
  • 765
6 votes
3 answers
1k views

Returning a large number of values from a thread

I have an application in which I am querying an XML web service continuously every 2 seconds in a thread. The returned XML is very big and I am retrieving lots of stuff from them using XPath and ...
swordfish's user avatar
  • 257
4 votes
1 answer
5k views

Mutex and condition variable implementation using futex

I have implemented mutex and conditional variables using the futex syscall. I believe that my implementation is correct, but would like it to be verified by someone ...
Sudhanshu's user avatar
5 votes
1 answer
1k views

Concurrent event counter/averager utility classes

For a personal project, I'm working on a Java profiler that specifically targets ThreadPoolExecutor and its subclasses and provides statistics about throughput of executed tasks. To support this I've ...
Mike Daniels's user avatar
1 vote
1 answer
4k views

Simple multi-threaded Java server loop

I'm new to sockets and servers in general and I would like to know if I'm doing something really wrong in the following server loop for spawning threads to process requests. ...
user avatar
7 votes
4 answers
2k views

Associating a lock/mutex with the data it protects

I've recently come across some areas of code in our solution that have a few thread-safety problems. Thread-safety is a minefield at best so I thought I'd have an attempt at writing a few little ...
Dom Crossley's user avatar
3 votes
3 answers
333 views

connect in a background until success

We have some required services down temporarily when our server start. So we need some reconnection logic for them until they are finally up. There is a requirement to have also syncronious way for ...
yetanothercoder's user avatar
2 votes
5 answers
2k views

Bounded blocking queue

Can someone please review this code for me? I have not implemented all the methods for simplicity. ...
p101's user avatar
  • 333
5 votes
1 answer
980 views

Processing a webpage source

I have developed a test app that works by getting webpages source and processing it. I have up to 100k URLs in queue and want to use a maximum of 25 threads. Please help me check if the code is good ...
Smith's user avatar
  • 277
5 votes
1 answer
6k views

Simple multithreading task

I wrote program which simulates the work of the restaurant. It works but I would like to change it because I think there is better solution.Thanks for your suggestions. Client.java ...
andre123's user avatar
2 votes
1 answer
1k views

multiple threaded program vb.net

i have this code that is suppose to work with at starting the minimum number of threads, say 5. when it starts the first five threads, it automatically replaces any thread that is finished making ...
Smith's user avatar
  • 277
3 votes
1 answer
10k views

Determining if current thread is executing

Using C#, create a class which gets an action (parameter-less delegate) in its construction and has a single public method bool execute() which does the ...
Mahendran's user avatar
1 vote
3 answers
762 views

Is my multithreaded form code correct?

The basic idea is this: There are two buttons: a DoWork button and a Cancel button. The ...
user420667's user avatar
6 votes
2 answers
14k views

Asynchronous Sockets

I need to implement a TCP client application. The client and the server send messages to each other. I want to make this program scalable enough to handle connections to multiple servers at the same ...
Andrew's user avatar
  • 61
8 votes
1 answer
4k views

C++ critical section with timeout

NOTE: My implementation is based on codeproject article by Vladislav Gelfer. Based on valdok's codes, I rewrote the critical section class. The difference is that my implementation integrated ...
Daniel K.'s user avatar
  • 333
2 votes
3 answers
1k views

Multi-Threaded Memory Preallocation

I need to figure out the best way to deal with memory pre-allocation Below is pseudo-code for what I am doing now, and it seems to be working fine. I am sure there is a better way to do this, I ...
rossb83's user avatar
  • 133
7 votes
1 answer
9k views

Multithreaded host pinging application

I'm working on a network monitoring application, that pings an unknown number of hosts. I've made a class PingHost with a function ...
Vlady V's user avatar
  • 71
10 votes
2 answers
533 views

Ruby script on-all-nodes-run not only for teaching

I wrote the following Ruby script several years ago and have been using it often ever since on a Bioinformatics computer cluster. It pulls out a list of hosts from the Torque queuing system ...
Aleksandr Levchuk's user avatar
7 votes
1 answer
450 views

Implementation of costreams

I am not very good with thread-safety and often fall prey to subtle issues in concurrency. Therefore, I hope that someone here might be able to tell me whether there is a subtle concurrency issue (...
Timwi's user avatar
  • 1,124
3 votes
2 answers
541 views

Composable Locks using LINQ. Can anyone see any problem with this ?

I was playing around with LINQ and I came up with the following idea for composing locks taking advantage of C# Monadic syntax. It seems too simple, so I thought let me post it on StackExchange and ...
user avatar
19 votes
5 answers
24k views

A custom thread-pool/queue class

I wanted a class which executes any number of tasks but only a certain amount at the same time (e.g. to download various internet content and keep the overall download speed at a good level). The ...
H.B.'s user avatar
  • 335
8 votes
3 answers
4k views

Java synchronous queue implementation

I just want to make sure there aren't any deadlocks or inconsistencies (the code is also available on GitHub). Disclaimer - In real life, I would not implement a queue myself, but use an existing ...
ripper234's user avatar
  • 261
8 votes
2 answers
1k views

Multithreaded log test

I'm writing a logger extension that allows multiple threads to log a process, and then dump that log to the main log in one atomic operation. The point of it is to make the logs easier to read when ...
Michael K's user avatar
  • 2,889
8 votes
4 answers
546 views

Spawning threads to process data

I have a class that spawns threads to process data. I am working on instrumentation code. When the process is started, time = System.currentTimeMillis(); When it ...
Michael K's user avatar
  • 2,889
49 votes
5 answers
15k views

Thread-Safe and Lock-Free - Queue Implementation

I was trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...
Hosam Aly's user avatar
  • 1,301
14 votes
3 answers
1k views

Fetching tweets

I have written this (truncated) code to fetch some tweets: ...
user avatar

1
28 29 30 31
32