multithreading

Multi-Threaded Application - Help with some pseudo code!!

I am working on a multi-threaded application and need help with some pseudo-code. To make it simpler for implementation I will try to explain that in simple terms / test case. Here is the scenario - I have an array list of strings (say 100 strings) I have a Reader Class that reads the strings and passes them to a Writer Class that pri...

Python - multithreading / multiprocessing, very strange problem.

Module run via python myscript.py (not shell input) import uuid import time import multiprocessing def sleep_then_write(content): time.sleep(5) print(content) if __name__ == '__main__': for i in range(15): p = multiprocessing.Process(target=sleep_then_write, args=('Hello World',...

Thread scheduling Round Robin / scheduling dispatch

#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <semaphore.h> #define NUM_THREADS 4 #define COUNT_LIMIT 13 int done = 0; int count = 0; int quantum = 2; int thread_ids[4] = {0,1,2,3}; int thread_runtime[4] = {0,5,4,7}; pthread_mutex_t count_mutex; pthread_cond_t count_threshold_cv; void * inc_c...

C# Importing Large Volume of Data from CSV to Database

What's the most efficient method to load large volumes of data from CSV (3 million + rows) to a database. The data needs to be formatted(e.g. name column needs to be split into first name and last name, etc.) I need to do this in a efficiently as possible i.e. time constraints I am siding with the option of reading, transforming an...

How do I make a background thread in Java that allows the main application to exit completely? This works in Linux, but not in Windows.

I have a Java application that creates a new thread to do some work. I can launch the new thread with no problems. When the "main" program terminates, I want the thread I created to keep running - which it does... But the problem is, when I run the main application from Eclipse or from Ant under Windows, control doesn't return unles...

Queuing methods to be run on an object by different threads in Python

Let's say I have an object who's class definition looks like: class Command: foo = 5 def run(self, bar): time.sleep(1) self.foo = bar return self.foo If this class is instantiated once, but different threads are hitting its run method (via an HTTP request, handled separately) passing in different args, what is the best...

how to call the method in thread with aruguments and return some value

i like to call the method in thread with aruguments and return some value here example class Program { static void Main() { Thread FirstThread = new Thread(new ThreadStart(Fun1)); Thread SecondThread = new Thread(new ThreadStart(Fun2)); FirstThread.Start(); SecondThread...

Asynchronous database update in Django?

I have a big form on my site. When the users fill it out and submit it, most of the data just gets dumped to the database, and then they get redirected to a new page. However, I'd also like to use the data to query another site, and then parse the results. That might take a bit longer. It's not essential that the user sees these results ...

find out the number of threads created by a short running program

I have program that runs fast enough. I want to see the number of threads created by the program. ldd test shows use of library pthread. but how to find out number of threads created by the program. I only have command line access to the PC on which the program is run. The platform is linux. ...

How to call a new thread from button click

Hi, I'm trying to call a thread on a button click (btn_more) but i cant get it right. The thread is to get some data and update the images. The problem i have is if i only update 4 or 5 images then it works fine. But if i load more than 5 images i will get a force close. At times when the internet is slow I will face the same problem to...

What strategies are efficient to handle concurrent reads on heterogeneous multi-core architectures?

I am tackling the challenge of using both the capabilities of a 8 core machine and a high-end GPU (Tesla 10). I have one big input file, one thread for each core, and one for the the GPU handling. The Gpu thread, to be efficient, needs a big number of lines from the input, while the Cpu thread needs only one line to proceed (storing mul...

gdb : multithreading

Hi, I have a program which uses two threads. I have put the break point in both the threads. While running the program under gdb I want to switch between the threads and make them run. (thread t1 is active and running and thread t2; when paused on the breakpoint. I want to stop T1 running and run the T2). Is there any way that I can sc...

Why am I getting a segmentation fault when I use binmode with threads in Perl?

Hi Folks, this call my $th = threads->create(\&print, "Hello thread World!\n"); $th->join(); works fine. But as soon as I add binmode(STDOUT, ":encoding(ISO-8859-1)"); to my script file, I get an error like "segmentation fault", "access denied". What is wrong to define an encoding type when trying to call a perl thread? Example:...

Read a value being manipulated in different thread

Hi... I'm trying to read a static property from a static class, which is being modified from a different thread. Basically I have this static class: public static class Progress{ public static int currentProgress{get; set;} } and this thread manipulating the currentProgress: private void Job(){ for(int i = 0; i<100; i++){ ...

How to craete batch files and execute them simultaneously usign C# thread

Hi... I have code for Database which is about of 4000 lines. It takes around 30 40 min. for executing. I want to create 20 batch files containing equal lines of command so that I can start them at same time using thread. Can anyone please guide me how should I proceed so that the time it normally takes to execute is reduced. Thanks, ...

What should be the ideal number of parallel java threads for copying a large set of files from a quad core ubuntu linux box to an external shared folder?

What should be the ideal number of parallel java threads for copying a large set of files from a quad core linux box to an external shared folder? I can see that with a single thread it is taking a hell lot of time to move the files one by one. Multiple threads is improving the copy performance, but I don't know what should be the exact ...

Java performance problem with LinkedBlockingQueue

Hello, this is my first post on stackoverflow... I hope someone can help me I have a big performance regression with Java 6 LinkedBlockingQueue. In the first thread i generate some objects which i push in to the queue In the second thread i pull these objects out. The performance regression occurs when the take() method of the Linked...

conceptual question : what do performSelectorOnMainThread do?

Hello all, I just come across this strange situation . I was using the technique of lazy image loading from apple examples . when I was used the class in my application it gave me topic to learn but don't what was actually happening there . So here goes the scenario : I think everybody has seen the apple lazytableimagesloading . I...

Run a UNIX command in a thread from a Bash script

Hiya, Problem background I have a post-commit script for my SVN repository which archives & backs up the incremental dumpfiles when a checkin is made. I'd like to update this to make an off-site backup, however the off-site copy could take a few minutes to complete if the checkin is large. Question Is it possible in a UNIX bash scri...

Java: Allowing the child thread to kill itself on InterruptedException?

I am using a ThreadPool via ExecutorService. By calling shutDownNow() it interrupts all running threads in the pool. When this happens I want these threads to give up their resources (socket and db connections) and simply die, but without continuing to run anymore logic, eg: inserting anything into the DB. What is the simplest way to ach...