multithreading

How to construct a new WPF form from a different thread in c#

I'm having trouble with the concept of threads and how to use them. I'm trying to code a fairly basic chat program (as part of a larger program) and it currently works like this: The 'NetworkSession' class receives the input from the server on a separate thread in a loop. If it receives input that indicates it should open a new chat wi...

Thread safety when iterating through concurrent collections

Hey, I'm writing some client-server-application where I have to deal with multiple threads. I've got some servers, that send alive-packets every few seconds. Those servers are maintained in a ConcurrentHashMap, that contains their EndPoints paired with the time the last alive-package arrived of the respective server. Now I've got a thr...

What threading module should I use to prevent disk IO from blocking network IO?

I have a Python application that, to be brief, receives data from a remote server, processes it, responds to the server, and occasionally saves the processed data to disk. The problem I've encountered is that there is a lot of data to write, and the save process can take upwards of half a minute. This is apparently a blocking operation, ...

How can I make sure all of my c++ boost threads finish before the program exits?

I know I can call thread.join() to force a thread to complete before the current thread can proceed. However, my program has a bunch of files that are read into memory, modified, and then flushed to disk. Each flush is being done in a separate thread so that the current thread can continue while the contents are flushed to disk. I could...

I'm having troubles understanding msdn's documentation about _beginthreadex and _endthreadex

I'm reading the documentation about _beginthreadex and _endthreadex but there are a few things I don't understand. Note that the documentation keeps documenting the "extended" and normal functions at the same time, but I'm not using _beginthread and _endthread; only their extended versions. You can call _endthread or _endthreade...

How can I create a new thread from a c++ boost thread_group that begins execution in a member function of an object?

There are some member variables and mutexes associated with the object, so it would be easier to use a member function rather than a standalone function. ...

Are there any drawbacks with ConcurrentHashMap?

I need a HashMap that is accessible from multiple threads. There are two simple options, using a normal HashMap and synchronizing on it or using a ConcurrentHashMap. Since ConcurrentHashMap does not block on read operations it seems much better suited for my needs (almost exclusively reads, almost never updates). On the other hand, I ...

How can a thread function access variables of the parent thread

I read that threads share the memory address space of it's parent thread. If that is true , why can't a thread function access a local variable belonging to it's parent thread ? void* PrintVar(void* arg){ printf( "%d\n", a); } int main(int argc, char*argv[]) { int a; a = 10; pthread_t thr; pthread_create( &thr, NULL, Pri...

Android thread problem, why ui still blocks when i have used a worker thread?

package com.commonsware.android.threads; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.View.OnClickListener; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; public class HandlerDem...

deadlock and synchronization in java

I have a question, I am always asked this in the interviews multiple times-- How is synchronization implemented in java.. I have answered-- using trylock() mechanism using wait, notify ,and notifyAll() methods in java using synchronized blocks using synchronized for class and object level using mutexes for synchronization using re-entr...

Using awt Paint in Multi threading

Hello everyone, I have a school project and i want to dedicate this for New Year, the project that i came up is a Text-Firework, i am using characters and symbols as the Explosion particles, and just constantly changing their X and Y position inside Paint(). I am confused on how to use Paint and Thread together. The problem is it's not...

Which thread will get the lock?

suppose we have multi processor machine and multi threaded application. If two threads have access to a synchronized method and they got executed at the same time which thread will gets the lock? or what will happen? Thanks ...

Parallel: how to synchronize properly

I have a following fairly simple scenario: Some data needs to be written into a DB (pretty big collection) that can be partitioned. But I have two problems: Easy one: would like to have an option to print the progress bar, so that would like to know how many records have been inserted so far from time to time (kinda shared counter amon...

How to write a port scanner listening for 'ACK' in python?

please can anyone help me with the port scanner program to scan ports on the IP address provided,for ACK. i want to know the technique used to scan for ACK & use multi-threading so please help me in that perspective. Thank you ...

Android 2.2: ProgressDialog Freezing In Second Thread

I have recently experimented with creating an easy way to open a ProgressDialog up in a second thread, so if the main thread freezes the dialog will keep working. Here is the class: public class ProgressDialogThread extends Thread { public Looper ThreadLooper; public Handler mHandler; public ProgressDialog ThreadDialog; public Cont...

A multithreaded task queue implementation in .NET.

Dear ladies and sirs. My headache is this - my server application exceeds the maximum open database connections while being under load. So, I figure I need a task queue (aka service bus) for write database access. A queue, that db write requests can be posted to it and the dedicate threads will read it and execute. I was wondering if t...

running a thread from within a vb.net webservice

Hi all I have a webservice with a webmethod that accepts an XML from a client via POST (don't know if this really matters), validates XML and the data inside, and then processes the XML and returns an answer to the client. At moment, I have a problem with large XMLs; it takes too long for the XML preprocessing to finish, and the clients...

Is there an advantage on the iPhone to breaking up an operation into multiple threads?

I have a method in my iPhone app that is very repetitive (called over and over and over sequentially). The method is quite bulky and takes about one second to complete. My question is this: If I was to muti-thread it to run, say 5 method calls on different threads simultaneously, would that be any faster than running 5 calls one after ...

Hi I am getting IlleagalMonitorStateException when I am trying to run this program

public class ThreadTest { public static Integer i = new Integer(0); public static void main(String[] args) throws InterruptedException { ThreadTest threadTest = new ThreadTest(); Runnable odd = threadTest.new Numbers(1, "thread1"); Runnable even = threadTest.new Numbers(0, "thread2"); ((Thread) odd).start(); ((Thread) even)...

Concurrent execution in apache/mod_php?

Hello, i am currently working on an MVC webframework with a very special feature. Layouts defined in XML files are seperated into content blocks that can be arranged/cached/loaded individually. Every content block (this could be e.g. the footer which is re-used on several pages) has some sort of Controller of its own. I call it Blockco...