All Questions
9 questions
-3
votes
1
answer
80
views
Will this time duration measurement in two threads give correct result?
A program I'm developing has two threads running similar but different task:
thread1:
timer1.start()
writeToExternalDB1(consumedData)
timer1.end()
thread2:
timer2.start()
writeToExternalDB2(...
1
vote
2
answers
529
views
What do you call a class that can be disabled [closed]
Is there a design pattern that fits this description? A factory that creates classes that can be disabled and enabled. The users of the class don't know if the functionality is enabled or disabled--...
9
votes
1
answer
9k
views
Why use ExecutorService for long-running thread?
I want an object that will spawn a daemon thread that will continue to run for the lifetime of the process. Let's say, just for the sake of the argument, that it's a thread in an embedded system, and ...
1
vote
1
answer
238
views
«Heavy» object initialization: within each thread or outside and then pass it to the threads as parameter?
Let say there is an array of strings, I have to process. I'm using a «heavy» third-part object which gets the string and performs its analysis. In order to optimize a performance, I create a number of ...
4
votes
3
answers
2k
views
Transitioning from C++ multithreading to Java multithreading
In C++, I've been accustomed to using threads in the following way:
#include <iostream>
#include <thread>
#include <mutex>
std::mutex m;
int i = 0;
void makeACallFromPhoneBooth()...
0
votes
2
answers
491
views
Built-in the separate thread execution inside of the method or wrap the method by the thread
Let assume, I have some resource and time-consuming code, which I want to arrange as a separate method. In order to optimize the performance, this code should be executed in the separate thread.
Now ...
1
vote
2
answers
90
views
Should I reference a CopyOnWriteArraySet from the Set interface?
There are two ways to use a CopyOnWriteArraySet:
// A
Set<Object> set = new CopyOnWriteArraySet<>();
and
// B
CopyOnWriteArraySet<Object> set = new CopyOnWriteArraySet<>();
...
3
votes
5
answers
3k
views
Should I build a multi-threaded system that handles events from a game and sorts them, independently, into different threads based on priority?
Can I build a multi-threaded system that handles events from a game and sorts them, independently, into different threads based on priority, and is it a good idea?
Here's more info:
I am about to ...
0
votes
1
answer
60
views
Where to put profile test?
I have an application with multiple threads that may be run on different hardware. To assist with tuning on different hardware I would like to create a "profiler" that can automatically run a fixed ...