I need to use a thread pool in python, and I want to be able to know when at least 1 thead out or "maximum threads allowed" has finished, so I can start it again if I still need to do something.
I has been using something like this:
def doSomethingWith(dataforthread):
dostuff()
i = i-1 #thread has finished
i = 0
poolSize = 5
t...
There are few built in ways to invoke a timer using the Android stack,
A good example is the Chronometer. (http://developer.android.com/reference/android/widget/Chronometer.html)
I would like to integrate piece of code (A thread)that implements timer using the Thread.sleep() method
I plan to have a Service tat invoke this thread and co...
Update : For anyone wondering what I went with at the end -
I divided the result-set into 4 and ran 4 instances of the same program with one argument each indicating what set to process. It did the trick for me. I also consider PP module. Though it worked, it prefer the same program. Please pitch in if this is a horrible implementation! ...
Hello all.
I'm a newbie to threading, trying to learn it as I go. Please don't make any assumptions and try to explain threading concepts and rules that might seem obvious.
I have a Module (Static class) as follows:
Module Main
Private ReadOnly _dbConn As SqlClient.SqlConnection
Public ReadOnly Property DBConn() As SqlClient.SqlConne...
My team built a Java application using the Hadoop libraries to transform a bunch of input files into useful output.
Given the current load a single multicore server will do fine for the coming year or so. We do not (yet) have the need to go for a multiserver Hadoop cluster, yet we chose to start this project "being prepared".
When I run...
Hello,
I have multiple threads which are serializing my 'Data' objects to files. The filename is based on 2 fields from the Object
class Data {
org.joda.DateTime time;
String title;
public String getFilename() {
return time.toString() + '_' + title + ".xml";
}
It is possible that 2 Data objects will have the...
Hi,
I came across a code which was using BeginInvoke to update label text in a certain way, which I found strange and I can't understand why would somebody do that.
If I want to use threading to allow good user experience, I would create a thread and update the labels in the new thread using Thread.Start nethod. Why would I use the b...
I am trying to use a background worker in order to retrieve a large amount of data from the database without stalling the main thread. This seems to work well, except that when it comes to update the UI, the update freezes the screen. Relevant code as follows:
private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEve...
I'm making a game with 5 objects moving around on the screen with SurfaceView. It's not a problem until a display all 5 objects to the screen. It displays a black screen. Any suggestion?
I'm using SurfaceView and use onDraw() to draw bitmaps.
...
I have a local scientific application that uses threads to process independent pieces of a large calculation. My group would like this to become a web application, so now I'm figuring out how to port it (so please forgive any complete bonehead statements). I'm using Google App Engine to take care of the "web" part of it, but I'm still ...
I built an app that performs work on thousands of files, then writes modified copies of these files to the disk. I am using a ThreadPool but it was spawning so many threads the pc was becoming unresponsive 260 total), so i changed the max from the default of 250 down to 50, this solved that issue (app only spawns about 60 threads total)...
(I use the term "asynchronously" loosely in the subject)
I've been using the below code for a while to save initial session context info to the DB such as affiliate details for later tracking. I've suggested others to use this concept to speed up some of their processes but i'd hate to be suggesting something that is potentially dangero...
I have a number of threads which wait on an event, perform some action, then wait on the event again. Another thread will trigger the event when it's appropriate.
I can't figure out a way to ensure that each waiting thread triggers exactly once upon the event being set. I currently have the triggering thread set it, sleep for a bit, the...
Having recently worked on a project which required some more IO interaction than I'm used to, I felt like I wanted to look past the regular libraries (Commons IO, in particular) and tackle some more in depth IO issues.
As an academic test, I decided to implement a basic, multi-threaded HTTP downloader. The idea is simple: provide a URL ...
hey guys
i am attempting to make an app that records an accurate location every 10 minutes.
the problem with this is that when running is best mode, the battery drains really quickly.
i would like a timer to turn of the location service, have didUpdateToLocation get a good location, turn of location service and then wait for the timer...
I know a little about assembly, and that there are 4 or 8 or so general purpose registers. How do all the programs on a computer work with just that amount of registers, especially with multithreading and everything?
...
Just wondered what that best approach is for this scenario - trying to databind to a collection which is being populated in another background thread.
My background thread is adding items to the collection in a processing loop which may run for several minutes. Every now and then it raises an event to the UI and passes a reference to t...
I have two definitions or methods in python. I'd like to run them at the same exact time. Originally I tried to use forking but since the child retained the memory from the parent, it's writing multiple things that I don't need in a file. So I switched to threading.
I have something similar to
import threading
class test(threading.Thr...
I know that this is ill advised but still i am trying to look into a method of interrupting a thread which hangs, from another thread which is keeping time.
What i do is:
I start the monitor thread just before a questionable network operation is about to happen. This thread is supposed to monitor the time elapsed since it was started an...
If I have a big array (400000 elems), a thread with highest priority and a sync read method
can we speak as STARVATION if this thread access it and not release the object for a long period of time to other threads with a low priority that so starve??
or the starvation is a term concerning only the case where a thread postpone indefinit...