multithreading

Does my local service spawn another thread?

Hello everyone, To be able to write "nice" code between my application/activies and a local service I need to understand some basic Android concepts: What I'm wondering is if my application (as in my activities) and my local service is sharing one thread. I.e. when the activities and the local service executes tasks queued are these ta...

JavaFX Multi Threading

I'm writing a small programm where JavaFx acts as a viewer and controler and let Java do the other hard work. I can start multiple threads from Javafx however, I'm not able to stop them. If I try to use .stop(), the threads are still running. Here is one of them: public var sleepTask_connect; function LogOutAction(): Void { sleepT...

In C/C++, are volatile variables guaranteed to have eventually consistent semantics betwen threads?

Is there any guarantee by any commonly followed standard (ISO C or C++, or any of the POSIX/SUS specifications) that a variable (perhaps marked volatile), not guarded by a mutex, that is being accessed by multiple threads will become eventually consistent if it is assigned to? To provide a specific example, consider two threads sharing ...

Using a queue in a multithreaded situation in C#

I just learned about queues in .NET and I have a few questions. Let's say that I'm building an application that downloads the HTML of pages and then processes it. Here's how I want it to operate: A main thread adds URLs to a queue This queue is read by two other threads. They "dequeue" a URL and then download the corresponding HTML. T...

CallContext in WCF

Hi, Is is safe to use CallContext when request arrives to WCF service, initialize it with some call specific data (for instance using hook at the beginning of call: Inspector/ContextBoundObject), and then reuse it in the call, and be guarantied that data I access is all the time the same data? Thanks, Pawel ...

Conflict on Locking two methods so that only 1 Thread can use the lock

Hi, I have a problem regarding multithreading and inserting an item to an Dictionary. The following situation is what I am encoutering when insertingen subjects with duplicate id's: private static readonly Timer bufferChecker; private static readonly List<SubjectStartRulePair> inBuffer; private static readonly IDictionary<Gu...

urllib2 and cookielib thread safety

As far as I've been able to tell cookielib isnt thread safe; but then again the post stating so is five years old, so it might be wrong. Nevertheless, I've been wondering - If I spawn a class like this: class Acc: jar = cookielib.CookieJar() cookie = urllib2.HTTPCookieProcessor(jar) opener = urllib2.build_opener(coo...

.Net Threading - Will a thread lock all sync blocks for a single locking object

Consider the following code snippet within a class private static Object _syncroot = new Object(); public void DoSomeWork() { // do some processing code lock(_syncroot) { // process some shared data } // do some processing code lock(_syncroot) { // do some further processing of shared data } } If this cod...

Running Log4Net appenders on separate thread

Here's the deal: Currently, I've got my own logging system, where the log is essentially a queue, with a separate thread listening to that queue and doing all of the actual write operations. The system processes a TON of log messages, files can easily exceed 10 MB sizes in minutes, so doing the actual logging in the calling thread is not...

How to improve performance through Python multithreading

I'm new to Python and multithreading, so please bear with me. I'm writing a script to process domains in a list through Web of Trust, a service that ranks websites from 1-100 on a scale of "trustworthiness", and write them to a CSV. Unfortunately Web of Trust's servers can take quite a while to respond, and processing 100k domains can t...

Regarding the deallocation of memory resources of a thread

Hi, I was going through the man pages of pthread_join and its mentioned the following "When a joinable thread terminates, its memory resources (thread descriptor and stack) are not deallocated until another thread performs pthread_join on it. Therefore, pthread_join must be called once for each joinable ...

Grails and multithread process

Hi, I have a grails app and I need to trigger an cpu-intensive process. I'm thinking in creating a service that spawns multiple threads that do the same calculations but with random data to compare the results later on. Is it safe to do it this way ? Any recommendations / experiences ? Thanks. ...

Python threading unexpectedly slower

I have decided to learn how multi-threading is done in Python, and I did a comparison to see what kind of performance gain I would get on a dual-core CPU. I found that my simple multi-threaded code actually runs slower than the sequential equivalent, and I cant figure out why. The test I contrived was to generate a large list of random ...

Why does lock(this) thread.sleep not work with ASP.NET threading ?

Hi I have a password page and when someone enters an incorrect password I want to simply foil a brute force attack by having bool isGoodPassword = (password == expected_password); lock (this) { if (!isGoodPassword) Thread.Sleep(2000); } I would expect that this would allow all correct passwords without stalling, but ...

HDF5 write thread concurrency

hi. Is hdf5 able to handle multiple threads on its own, or does it have to be externally synchronized? OpenMP example suggests later. if former, what is the proper way to define dataspace to write? thank you ...

How can I fix this multithreaded Python script?

I'm writing a python script to read through a list of domains, find out what rating Mcafee's Siteadvisor service gives, then output the domain and result to a CSV. I've based my script off this previous answer. It uses the urllib to scrape Siteadvisor's page for the domain in question (not the best method, I know, but Siteadvisor provid...

Using volatile long as an atomic

If I have something like this... volatile long something_global = 0; long some_public_func() { return something_global++; } Would it be reasonable to expect this code to not break (race condition) when accessed with multiple threads? If it's not standard, could it still be done as a reasonable assumption about modern compilers? ...

In Tcl, seg faults from multiple threads requiring Expect

Now here's something interesting. When I have more than one thread in Tcl invoking package require Expect, I get a seg fault. e.g. package require Threads package require Expect set t [thread::create] thread::send {package require Expect} puts "blarg! Damned thing crashes before I get here" This is not a good time. Any thoughts?...

atomicity in 32/64 bit

the question is about when does a 64bit load/store operations are considered to be atomic. if i have a 64bit processor, but i'm using 32bit OS. Will i have 64bit atomicity? if i'm using 64bit OS but running an 32bit application (using WoW64), will i have 64bit atomicity? ...

simplifying threading in python

I am looking for a way to ease my threaded code. There are a lot of places in my code where I do something like: for arg in array: t=Thread(lambda:myFunction(arg)) t.start() i.e running the same function, each time for different parameters, in threads. This is of course a simplified version of the real code, and usually the co...