New answers tagged

1

A quick non-academic view: Dynamic model: Pros: uses only the number of threads needed. Cons: the overhead of the thread creation and deletion during the processing. Consider also thread switching overhead, if the number of dynamic threads increases over the hardware supported limit. Typical use case: handling event driven processes/sessions (e.g. I/...


3

Use database connection pooling. I don't recommend writing your own. Here's an explanation on StackOverflow. You can use c3p0 or read up more on your own by searching for "connection pooling."


0

This is an old question, but in case you are still interested, you might look at Qore, which is an interpreted language with fundamental support for multithreading and also has a unique garbage collection approach (Prompt Collection) which allows for the language to support the RAII idiom (c++-like destructors for resource management and exception-safe ...


2

(I am not sure to understand what you want; I'm trying to guess; asynchronous IO could mean aio(7) but then you won't speak of threads to do them; however I am supposing you are on Linux - adapt my answer to other OSes) You might consider using condition variables using std::condition_variable with std::mutex (probably some other thread would signal the ...


2

First, is it safe to create a private static list and search/modify it from multiple threads? No. At the very least you'll want to use one of the concurrent collections. This may not be enough. For example, if you need to execute multiple operations against the list before any other thread touches it, you'll need some other sort of locking. How to ...


0

Compilation is an "embarrassingly parallel" problem. Nobody cares about the time for compiling one file. People care about the time of compiling 1000 files. And for 1000 files, each core of the processor can happily compile one file at a time, keeping all cores totally busy.


9

Large software projects are usually composed of many compilation units that can be compiled relatively independently, and so compilation is often parallelized at a very rough granularity by invoking the compiler several times in parallel. This happens at the level of OS processes and is coordinated by the build system rather than the compiler proper. I ...


2

This is a very broad topic. Unfortunately there's no general answer, due to the complex matter of patentability. And in view of the existing practice of patent trolling, there is always be some legal risk to be sued in countries in which software patents are accepted. As a first intro, you may be interested in this WIPO article, and especially TIP3, about ...


1

You're mostly on the right track. The stack's purpose in general is to hang onto data you'll need later. Most of the time, that's done when calling subroutines, at the very least to save the return address, but also to save any state that may be destroyed otherwise and as a mechanism to store local variables and to pass parameters. In most multitasking ...


1

The stack has nothing to do with multi-threading. The stack saves information about a subroutine. When I say sub-routine, I am not speaking about any particular language, but the process of making a call to another area of the program space, and returning from that area when finished. When making the call, the currently executing routine may be using ...


2

As Dan Pichelman pointed out in his answer, it looks like you're running into large amounts of context switches. Here's what's going on in ASCII art form, on a simpler three core computer. I'll have context switches use one time period each, and do 24 time periods of work divided evenly among the threads. In order to avoid starving threads of runtime, there ...


5

Sounds like you're running into Context Switching issues. (The linked article talks about entire processes rather than threads, but the idea is similar) There is a very real cost incurred when a CPU switches from working on one thing to working on another. As you've discovered, when the number of CPUs roughly matches the number of threads, the CPUs don't ...


0

I wrote a completely different answer, suggesting that your publisher writes updates to a queue or a pipe -- but I then I re-read the question. If I understand right your general question is that you want to write a library to run in the JRE, in which a native front-end can query the state of Java objects in a thread-safe manner. This is incredibly broad ...



Top 50 recent answers are included