Using libpcap to collect connection statistics

I have a HTTP threading proxy, i.e. for every request from clients I spawn a thread: now I want to gather some stats like bits per second (bps) and packets per second (pps). I like my code to do one thing only, so if a thread handles a connection it

Can a thread directly wait for another thread?

In Java, is it possible for one thread to cause another thread to wait by calling wait(), or without signaling of some kind? I'm not actually trying to achieve or implement some practical end, like in the post How to synchronize shared data between t

How do I have a function to repeat in java?

I am making a slapjack game where the deck will need to give to cards to the slapzone every 5 seconds and flip the image for 2 seconds before turning the picture back over. I know i will have to use a thread, but i can't figure out how to say repeat

Java NIO TCP Timeout Problem

I am using one SocketChannel in 2 threads, one thread for sending the data and another for receiving the data. SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress(ip,port)); socketChannel.configureBlocking(false); Thread 1: uses th

Thread Safety and Task.Factory

I'm quite new in parallel programing i'd like to do some work with tasks every task is initiated with param to do some simple work with id but it seems the params all mixed up.. i'm sure i'm missing some key element in thread safety can you help me u

Using a thread with designer objects vb.net

I have a big problem. I am currently designing an Antivirus, and it is coming along very well. But having all the scanning engines running on the same thread, I.E. the main one, is causing the app to lag in loading, and to become unresponsive during

Kill the wire nearby

I have a constructor of a JFrame where I have a Thread(t1) which is running thanks to a while(true) I would like to know how to implement my JFrame so it can kill the thread when I close it, because t1 need to be running when the JFrame is active EDI

Is the GWT an asynccallback cushion in a safe manufacturer?

Assuming the constructor runs in the client part of the code (the one that gets translated to javascript). The callback method onSuccess does modify the instance variables of the class. The callback is implemented as an anonymous class so the instanc

The code works for a while then you just have to stop

I have made an application that monitors an interface and returns a packets per second reading, how ever when executed it runs fine for about 30 seconds till I open a YouTube page to get the counter running a little high. A couple of seconds later th

Booster ASIO IO_SERVICE Implementation?

I was writing an asynchronous logging framework, where I had multiple threads dumping data. I started playing around Boost asio because it offered some easy ways to enforce serialization and ordering. Since I am a beginner, I started my design with a

Stopping an Android service from a thread

I have a Service which starts a thread during onCreate(). The thread is monitoring hardware (IOIO) and will end once it is disconnected so essesentially is an infinite loop. Stopping the service from an Activity works fine and the thread also stops (

C ++ terminated calling without exception

I am getting a C++ error with threading: terminate called without an active exception Aborted Here is the code: #include <queue> #include <thread> #include <mutex> #include <condition_variable> template<typename TYPE> class b

What is the difference between deadlock and livelock?

Can somebody please explain with examples (of code) what is the difference between deadlock and livelock?Taken from http://en.wikipedia.org/wiki/Deadlock: In concurrent computing, a deadlock is a state in which each member of a group of actions, is w

Thread.sleep waits more than expected

The following code: long msBefore = System.currentTimeMillis(); //Thread.currentThread().setPriority(Thread.MAX_PRIORITY); try {Thread.sleep(200); } catch (InterruptedException e){} System.out.println("Time: " + (System.currentTimeMillis() - msB

Refactoring Dictionary to ConcurrentDictionary

I want to make my code multithreadable, therefor i need to change a Dictionary into a ConcurrentDictionary. I read about the ConcurrentDictionary, checked some example, but still I need a hand on this: Here is the original code (for single thread) pr

Loss of performance in C ++ 0x and static local variables?

What is a realistic performance loss due to the fact that in C++0x all other threads shall wait in a case like this: string& program_name() { static string instance = "Parallel Pi"; return instance; } Lets assume the optimal scenario: The pr

Retrieving a DataGridView with Text and ProgressBars

I am creating a multi-threaded application in which each thread will appear as a row in my DataGridView. I want a ProgressBar in each row indicating the corresponding thread progress. The question is, is this possible? And if so, how?I added class Da

How do I block until a thread is returned to the pool?

As part of a windows service I'm accepting incoming socket connection using myListener.BeginAcceptSocket(acceptAsync, null) The acceptAsync function executes on a seperate thread (just as expected). When the service is requested to shutdown, I "signa

How to design a multithreaded application

I have a multithreaded application. Each module is executed in a separate thread. Modules are: - network module - used to receive/send data from network - parser module - encode/decode network data to internal presentation - 2 application module - pe

Multi-threaded java access to primitive variables

I know that concurrently accessing the same object from different threads, without synchronisation, is in general a bad thing. But what about this case: I have multiple threads running (consider two, ThreadA & ThreadB). I also have this static class

Using my application memory increases using pthread

I am using C language and Linux as my programming platform. In my user-space application. I used pthread to create a thread. int main() { pthread_t thread1, thread2; pthread_create( &thread1, NULL, fthread1, NULL ); pthread_create( &thread2, NULL,

How to use threading in Python?

I am trying to understand threading in Python. I've looked at the documentation and examples, but quite frankly, many examples are overly sophisticated and I'm having trouble understanding them. How do you clearly show tasks being divided for multi-t

Multithreading / Parallel processing in PHP

I have a PHP script that will generate a report using PHPExcel from data queried from a MySQL DB. Currently, it is linear in processing in that it gets the data back from MySQL, reads in the Excel template, writes the data to the template, then outpu