New answers tagged

1

Actually, in worst case, none of your threads may be executing. Linux has plenty of its own threads that it also needs to schedule. You can always request to run multiple threads, but only by assigning a high priority to them can you hope to have them running simultaneously. No guarantees. Assigning a core affinity to a thread is a bad idea. That could ...


2

Congratulations, your testing has now progressed to the stage where 'integration testing' is required. You have mentioned that in addition to u it testing you have done some general testing so far as well and have also put everything together and noticed that the testing reveals undesirable performance. Integration testing is all about how all individual ...


2

The first thing to realize is that the situation you describe (some items are 'never' processed) can only arise if you simply don't have the capacity to handle the volume of requests. If you have the capacity to handle the expected volume of requests over a given time period, you will be able to handle all the requests. This is a tautology. Changing the ...


2

On android you can use AsyncTask (the equivalent of SwingWorker). It has 3 methods you can override, doInBackground for the work you want to do in the background thread, onPostExecute called on the UI thread with the return value of doInBackground after it returns, and onProgressUpdate also called on the UI thread in responce to calls to ...


0

There's a simple way to do this: You set up an object with the synchronized data and share it between the threads. You can then write the data or check for it from each thread. So, you'd have an instance of a class that looks like this: public class Shared { private boolean signalSent = false; public synchronized boolean isSignalSent(){ ...


-2

i think you can do this using common method in both the thread , for example 1 thread can get the input from the user and process on that and successfully processed than it update the common method and 2 thread continuously check the common method if it is updated or not if it is updated than it start process on that.


6

The scheduling mechanism you have described is Fixed-priority pre-emptive scheduling. If you know there is a possibility the max priority queue is always full, then you are using the wrong mechanism, because of starvation as you described. You could prevent starvation by using a different scheduler. For instance, you can say that you process at most f(...


3

Basically you're making priority a function of two variables, like pricePaid*A + waitingTime*B. That's a perfectly sensible strategy. Suppose you're selling tickets, and the price people pay puts them into one of the queues - high, medium, low. You could look at that as a single ordered priority queue, where the priority is high, medium, or low. Within each ...


1

Are there any performance implications I need to know about when a thread of highest priority is entering the region v.s. a lower-priority thread trying to enter the region? A well-known problem with this situation is priority inversion: if a low-priority thread holds the lock, it may make the high-priority thread wait for a long time (because medium-...


1

A traditional non-threaded is actually a program with 1 thread. Now understanding that, in some OSes, processing in parallel is achieved by running multiple instances of a program. You wouldn't say that is exposing process internals to the OS, yet it is doing exactly the same thing that a multi-threaded program (ie one with OS support for multiple internal ...


4

I understand from your statement that in the case, the agent is run asynchronously in a separate thread. Imagine what would happen if the agent would execute synchronously: the monitoring service would call the agent and wait until the agent is finished. in the meantime it does no longer monitor anything perhaps even it will miss a good opportunity ...


2

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/...



Top 50 recent answers are included