thread-synchronization

Simultaneous mutable access to arbitrary indices of a large vector that are guaranteed to be disjoint

半城伤御伤魂 提交于 2019-12-01 17:38:45
问题 Context I have a case where multiple threads must update objects stored in a shared vector. However, the vector is very large, and the number of elements to update is relatively small. Problem In a minimal example, the set of elements to update can be identified by a (hash-)set containing the indices of elements to update. The code could hence look as follows: let mut big_vector_of_elements = generate_data_vector(); while has_things_to_do() { let indices_to_update = compute_indices(); indices

Implementing a synchronization barrier in Ruby

喜欢而已 提交于 2019-11-30 13:27:21
I'm trying to "replicate" the behaviour of CUDA's __synchtreads() function in Ruby. Specifically, I have a set of N threads that need to execute some code, then all wait on each other at mid-point in execution before continuing with the rest of their business. For example: x = 0 a = Thread.new do x = 1 syncthreads() end b = Thread.new do syncthreads() # x should have been changed raise if x == 0 end [a,b].each { |t| t.join } What tools do I need to use to accomplish this? I tried using a global hash, and then sleeping until all the threads have set a flag indicating they're done with the first

Implementing a synchronization barrier in Ruby

雨燕双飞 提交于 2019-11-29 19:05:59
问题 I'm trying to "replicate" the behaviour of CUDA's __synchtreads() function in Ruby. Specifically, I have a set of N threads that need to execute some code, then all wait on each other at mid-point in execution before continuing with the rest of their business. For example: x = 0 a = Thread.new do x = 1 syncthreads() end b = Thread.new do syncthreads() # x should have been changed raise if x == 0 end [a,b].each { |t| t.join } What tools do I need to use to accomplish this? I tried using a

Spring @Async limit number of threads

↘锁芯ラ 提交于 2019-11-27 22:47:48
My question is very similar to this one : @Async prevent a thread to continue until other thread have finished Basically i need run ~ hundreds of computations in more threads. I want to run only some amount of parallel threads e.g. 5 threads with 5 computationis in paralell. I am using spring framework and @Async option is natural choice. I do not need full-featured JMS queue, that`s a bit overhead for me. Any ideas ? Thank you Have you checked out Task Executor ? You can define a Thread Pool, with a maximum number of threads to execute your tasks. If you want to use it with @Async , use this

Spring @Async limit number of threads

夙愿已清 提交于 2019-11-26 23:12:25
问题 My question is very similar to this one : @Async prevent a thread to continue until other thread have finished Basically i need run ~ hundreds of computations in more threads. I want to run only some amount of parallel threads e.g. 5 threads with 5 computationis in paralell. I am using spring framework and @Async option is natural choice. I do not need full-featured JMS queue, that`s a bit overhead for me. Any ideas ? Thank you 回答1: Have you checked out Task Executor ? You can define a Thread