multithreading

memory fences/barriers in C++: does boost or other libraries have them?

I am reading these days about memory fences and barriers as a way to synchronize multithreaded code and avoid code reordering. I usually develop in C++ under Linux OS and I use boost libs massively but I am not able to find any class related to it. Do you know if memory barrier of fences are present in boost or if there is a way to ach...

JVM load not shared between processor cores on linux

Hey, how come that JVM always uses only one from four cores ? If I run 2 or 3 Java apps, one core is employed on 100% and the rest is sleeping having nothing to do. Apps like Liferay, eclipse, sonatype nexus etc., multithreaded overlords. There is plenty of free RAM also. ps and top shows what I just said, and entire system gets out ...

Multi-threaded Java server vs safe publication

When you google for multi-threaded java server, most of the time you'll get a solution based on a following pattern: public class MultiThreadServer implements Runnable { private Socket socket; MultiThreadServer(Socket socket) { this.socket = socket; } public static void main(String args[]) throws Exception { ServerSock...

sharing object protocol

Hi I would like to know if someone has some idea or feedback about sharing data between thread or processes ( through a shared memory segment ). I was thinking about passing across the threads/process some ownership object ( through a pipe/ synchronized queue ). The only thread that can access data are the one owning the ownership of th...

How can two concurrent threads or processes communicate?

Broadly, how does inter-process and inter-thread communication work? Clarification: I understand this question can't be exhaustively answered in one succinct paragraph. I'm looking for answers that will be a good starting point for beginners - high level concepts of how it works. ...

How do Application Servers support multi-threading?

I am looking for information regarding how application servers like Tomcat, Websphere, IIS etc support multi-threading to handle client requests. Is there a comparative analysis on how each of them support/handle concurrent requests? Thank you ...

Why lock is needed to implement a readonly int property?

I'm new to threading and I came accross a custom thread pool implementation example in a blog. I'm pasting just the necessary parts of the code: Public Class ThreadPool Private CountLock As New Object Private _Count As Integer Public ReadOnly Property ThreadCount() As Integer Get SyncLock CountLock ...

GDB: Debugging two threads simultaneously of a process

I have big process running. It spawns two threads. I want to debug those two threads separately. But there is only one gdb prompt. How to do this? Means I want to parallely see the execution of the threads. ...

How can I catch SIGINT in threading python program?

Hello. When using threading module and Thread() class, SIGINT (Ctrl+C in console) could not be catched. Why and what can I do? Simple test program: #!/usr/bin/env python import threading def test(suffix): while True: print "test", suffix def main(): for i in (1, 2, 3, 4, 5): threading.Thread(target=test, ar...

How much time spent in a .NET Thread?

I have a multi-threaded application with (4) thread i want to know how much processing time spent in threads. I've created all these threads with ThreadPool Thread1 doing job1 Thread2 doing job2 .. .. result would be: Thread1 was running in 12 millisecond Thread2 was running in 20 millisecond I've actually download a web page in a jo...

WX.Python and multiprocessing

I have a wx.python application that takes some files and processes them when a button is clicked. I need to process them in parallel. I use this code inside the bound button function: my_pool = multiprocessing.Pool(POOLSIZE) results=[digest_pool.apply_async(self.fun, [args]) for file in list_files() ] my_pool.close() my_pool...

execute SwingWorker multiple times

I want to be able to use SwingWorker subclass multi times is this possible as I have read in the java doc "SwingWorker is only designed to be executed once. Executing a SwingWorker more than once will not result in invoking the doInBackground method twice." Any ideas? Thanks ...

Volatile classes in C++

I have a question concerning volatile keyword I can't seem to find an answer for. In my app I have data class that is shared as a state buffer between threads, and I need it to be updated regularly from multiple threads. Class looks like this: class CBuffer { //Constructor, destructor, Critical section initialization/destruction ...

ThreadPool and Producer - Consumer pattern design question

I want to implement a Producer - Consumers pattern using a ThreadPool for the Consumers. I will have 1 producer of requests and multiple consumers that will handle the incoming requests. When Implement the consumers using a threadpool my question if I should still have my own Queue for the producer to put requests on and then pass them...

Best way to synchronize asynchronous task

Hi there, My Problem: I've got 802.15.4 Wireless network connected to a serial port (using a wrapper). I can send packages into the network and listen for incoming packages. As you can imagine this is highly asynchronous. Here comes the task: I want to send commands to the network and wait for the response in one function call. For Ex...

Can Interlocked class safely be mixed with lock()?

Is an atomic read guaranteed when you mix Interlocked operations with lock() (and other higher-level locks)? I am interested in general behaviour when mixing locking mechanisms like this, and any differences between Int32 and Int64. private Int64 count; private object _myLock; public Int64 Count { get { lock(_myLock) { ...

How to use lock_guard when returning protected data

I have a question concerning the use of boost::lock_guard (or similar scoped locks) and using variables that should be protected by the lock in a return statement. How is the order of destroying local objects and copying the return value? How does return value optimization affect this? Example: Data Class::GetData() { boost::lock_...

Why is my thread not starting immediately?

Hi, see below program. I start a new thread x with function abc, then I do some longer task. Why does x only start after end sub? Shouldn't it start right-away, before sleep ? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As New Threading.Thread(AddressOf abc) ...

Modify controls out of MainThread (Need some theory confirmation from pros)

Hello all! I have a winform with a form called MainForm. I have a static class called ObjMgr. In ObjMg, I have several other static classes, values, but Its not important now. In the ObjMgr class, I also have a static void Pulse() method, that I populate my other static classes in the ObjMgr. This pulse method have to run very often, l...

[Android] My "MyException" which shows Toast causes trouble while thrown in threads. How should I reorganize Exception handling?

I have written my own Exception (MyException) and implemented Logging and showing Error Messages in Form of Toasts. Here is the shortform of it... public class MyException extends Exception { public MyException(String msg) { Looper.prepare(); Toast.makeText(Controller.getInstance().getApplicationContext(), msg , Toast.L...