multithreading

How are applications run on multi-core machines?

I'm trying to gain a better understanding of how multi-core processors work and how as a programmer I can take advantage of them. Let's say I have a standard .net console app. It doesn't do any multithreading. Does it only run on 1 of the cores? If so which core does it run on and is it the same one everytime? Now let's say I have anot...

Retrieving properties from a GUI object in a thread

Guys, I have a C# program that executes a thread. Inside this thread, I have the following code: string strDropDownValue = (string)ddlVersion.SelectedItem; I am trying to retrieve the selected value from the drop down list. This line works, obviously, in a single threaded application. Because I'm doing this from a thread though, I ge...

How can I set the Properties of a DataGridViewComboBoxColumn in a thread? (C# Winforms)

I'm studying delegates and simple threading, I tried it in a ComboBox control, and experimented in a DataGridViewComboBoxColumn (cause I thought it would be the same) but it seems there's no Invoke property for this kind. How can I set DataGridViewComboBoxColumn properties in a thread? Please see my code, this works for setting the prop...

How will I know if my thread is already done doing tasks? (C# winforms)

With the code below, how will I know if my thread is already done doing tasks? My purpose is to kill that thread in order to free memory. Or how should I do it? private delegate void DelegateSetProperties(DataTable dataSource, string valueMember, string displayMember); Thread thread1; DelegateSetProperties delegateSetProperties...

"Refreshing" a fixed size thread pool when using for a ExecutorService

In my application, I use ExecutorService a lot for making async calls. ExecutorService executorService = Executors.newFixedThreadPool(10); And I shutdown the executorService only when the app (web based) shuts down. Recently when debugging some issues I was looking through this code and wondering whether there can be cases during the...

Silverlight HTTPRequest thread problem

I use the following code for handling an async response: private static void RespCallback(IAsyncResult ar) { // Get the RequestState object from the async result. RequestState rs = (RequestState)ar.AsyncState; // Get the WebRequest from RequestState. WebRequest req = rs.Re...

Intrusive or non intrusive

I am writing a multi threaded server app that requires stability and high performance. I'm looking at using Boost for some data structures I need. Is an intrusive data structure better or worse for something that should be thread safe and needs fast access, insertion, etc:::: ? ...

Possible memory leak using tomcat

I've developed a Webbapp that makes an extensive use of threads. We need to monitor some resources at fixed intervals and then act. To achieve this, we've developed a ThreadManager that wraps one ScheduledThreadPoolExecutor. We allow any of the methods of the executor, we only use this manager to make sure everybody uses the same instan...

Is it ok to create shared variables inside a thread?

I think this might be a fairly easy question. I found a lot of examples using threads and shared variables but in no example a shared variable was created inside a thread. I want to make sure I don't do something that seems to work and will break some time in the future. The reason I need this is I have a shared hash that maps keys to ...

Windows Forms GUI Stuck

lets say you are adding a feature to an old and running windows form application now the whole application is running in one thread and the application is really big and have many forms so you cant refract it to run in multithreads, now the application gui freeze everytime you make a process , is there is any way to have an indicator tha...

How to manage worker thread who wait until they have work to do ?

I have a program that does the following: Call webservice (there are many calls to the same web service) Process the result of 1. Insert result of 2. in a DB So I think it should be better to do some multithreading. I think I can do it like this: one thread is the master (let's call it A) it creates some thread which calls the webs...

Multithreading not faster than single thread (simple loop test)

I'm experimenting with some multithreading constructions, but somehow it seems that multithreading is not faster than a single thread. I narrowed it down to a very simple test with a nested loop (1000x1000) in which the system only counts. Below I posted the code for both single threading and multithreading and how they are executed. The...

How to pass values between threads?

I have a windows forms program with a form MainForm. On a button press I start a code that runs (pulses) on every 0.5secs on another thread. I want to modify many things, like labels, progressbars on my MainForm, from the Pulse method. How is this possible? So I would like to know, how to interract with variables, values, in that thread,...

Break on thread creation in Visual Studio debugger

Can I set the Visual Studio debugger to break on thread creation? (Note this is not the same as breaking on context switch as asked for in this other question: http://stackoverflow.com/questions/3048064/can-i-set-a-breakpoint-in-visual-studio-c-to-break-on-a-thread-context-switch) ...

Modifying common resource

My scenario is : I've an excel sheet. Some threads need to modify it at the same time. I need to implement this and I'm looking for a best practice solution. synchronizedmethod could be a solution? If yes, then wouldn't it create starvation problem or every thread may have to wait for long time? Is any other way round? ...

Is this the correct object to lock on for thread safety?

The code below is going to be called from a website so having a static dictionary object in a non static class needs to be threadsafe. Basically the purpose of the code is to encapsulate logic and to maintain the life-time of the perfmon counter(s), which are stored in an instance of CounterContainer. The constructor is called passing ...

Some questions about Threading in Java

First a little background. I got a warning in NetBeans told me not to start a new thread in a constructor. I have read that the reason for that is because the new thread might start and try to reference the object started the thread before the constructor is actually done making the object. 1.) For the sake of experimentation instead...

ThreadPool Parameters

I am testing a simple threadpool solution before I put it in my application, but the results I am seeing do not make sense for me. I have a simple form with one button on it. This button starts the following loop: private void button1_Click(object sender, EventArgs e) { MyTestThread oTask = new MyTestThread (); MyThreadInfo oTa...

"chunksize" parameter in Python's multiprocessing.Pool.map

If I have a pool object with 2 processors for example: p=multiprocessing.Pool(2) and I want to iterate over a list of files on directory and use the map function could someone explain what is the chunksize of this function: p.map(func, iterable[, chunksize]) If I set the chunksize for example to 10 does that means every 10 files s...

A CountDownLatch's latch.await() method vs Thread.join()

I saw a stackoverflow member suggest using Thread.join() to have a "main" thread wait for 2 "task" threads to complete. I will frequently do something different (shown below) and I want to know if there are any problems with my approach. final CountDownLatch latch = new CountDownLatch(myItems.length); for (Item item : myItems) { /...