multithreading

Eclipse RCP multithreading

余生颓废 提交于 2021-02-07 17:55:33
问题 I have an eclipse rcp application. And I have a command when this command is executing. I need to start a thread. After execution of this thread GUI must be updated. But I suppose that this thread or other non-SWT thread cannot update GUI. But it seems reasonable. When I was trying to do that I got Exception in thread "Thread-5" org.eclipse.swt.SWTException: Invalid thread access . How I can make this goal? 回答1: Using SWT you need to have anything that updates the GUI be done on the main

Play Scala and thread safety

被刻印的时光 ゝ 提交于 2021-02-07 15:40:15
问题 The project is written using Play framework and Scala language. I have implemented compile time dependency . I have followed this example from Play: https://github.com/playframework/play-scala-compile-di-example Looking at the MyApplicationLoader.scala : import play.api._ import play.api.routing.Router class MyApplicationLoader extends ApplicationLoader { private var components: MyComponents = _ def load(context: ApplicationLoader.Context): Application = { components = new MyComponents

Is there a known size limit of the thread local storage in a prevalent modern OS?

妖精的绣舞 提交于 2021-02-07 14:39:27
问题 When I use thread_local , _Thread_local , __thread , or __declspec(thread) , the compiler seems to allocate a thread local storage upon thread creation and store the address in the fs or gs register in an x86 derived system. In this context, is there something like 'thread local storage overflow'? 回答1: There are limits. Each system will be different, but on Windows, there is a limited data section which is mapped thread specifically. The size of this section is limited. Older versions of

Scala Future/Promise fast-fail pipeline

风流意气都作罢 提交于 2021-02-07 13:58:16
问题 I want to launch two or more Future/Promises in parallel and fail even if one of the launched Future/Promise fails and dont want to wait for the rest to complete. What is the most idiomatic way to compose this pipeline in Scala. EDIT: more contextual information. I have to launch two external processes one writing to a fifo file and another reading from it. Say if the writer process fails; the reader thread might hang forever waiting for any input from the file. So I would want to launch both

Multiprocessing slower than serial processing in Windows (but not in Linux)

时光毁灭记忆、已成空白 提交于 2021-02-07 13:56:12
问题 I'm trying to parallelize a for loop to speed-up my code, since the loop processing operations are all independent. Following online tutorials, it seems the standard multiprocessing library in Python is a good start, and I've got this working for basic examples. However, for my actual use case, I find that parallel processing (using a dual core machine) is actually a little (<5%) slower, when run on Windows. Running the same code on Linux, however, results in a parallel processing speed-up of

Does this envelope implementation correctly use C++11 atomics?

ぃ、小莉子 提交于 2021-02-07 13:15:54
问题 I have written a simple 'envelope' class to make sure I understand the C++11 atomic semantics correctly. I have a header and a payload, where the writer clears the header, fills in the payload, then fills the header with an increasing integer. The idea is that a reader then can read the header, memcpy out the payload, read the header again, and if the header is the same the reader can then assume they successfully copied the payload. It's OK that the reader may miss some updates, but it's not

Python: Stop thread that is waiting for user input

那年仲夏 提交于 2021-02-07 13:13:12
问题 I'm trying to have my script trigger a user input when the user pressed the return key. The main program will then check the txUpdated flag and use this input. I have a thread running in python that simply waits for user input: class InputThread(threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): global screenLock global txUpdated global txMessage global endFlag lock = threading.Lock() print "Starting

Python: Stop thread that is waiting for user input

寵の児 提交于 2021-02-07 13:10:56
问题 I'm trying to have my script trigger a user input when the user pressed the return key. The main program will then check the txUpdated flag and use this input. I have a thread running in python that simply waits for user input: class InputThread(threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): global screenLock global txUpdated global txMessage global endFlag lock = threading.Lock() print "Starting

Hardware thread vs soft threads?

孤者浪人 提交于 2021-02-07 12:53:19
问题 I have read that in a multi core processor each core contains 2 hardware threads for example in dual core processor 4 hardware threads are running. Now if i create 2 threads in java are those threads going to map with 2 hardware threads or those 2 java threads are executed by single hardware thread of a particular core ? 回答1: That is dependent on a lot of things, however the 2 hardware threads per core you are referring to is the Intel HyperThreading technology. This technology enables the

Do operations on ThreadLocal have to be synchronized?

百般思念 提交于 2021-02-07 12:52:47
问题 Here is the code I've stumbled across: class TransactionContextHolder { private static final ThreadLocal<TransactionContext> currentTransactionContext = new NamedInheritableThreadLocal<TransactionContext>( "Test Transaction Context"); static TransactionContext getCurrentTransactionContext() { return currentTransactionContext.get(); } static void setCurrentTransactionContext(TransactionContext transactionContext) { currentTransactionContext.set(transactionContext); } static TransactionContext