threadpoolexecutor

ThreadPoolExecutor parameter configuration

纵饮孤独 提交于 2021-02-20 02:30:43
问题 I'm working with a client application which needs to request data from a Rest API. Many of these requests are independent, so they could be called asynchronously. I'm using ThreadPoolExecutor to do so, and I've seen it can be configured with several parameters: corePoolSize maxPoolSize queueCapacity I read this article and I understand the following: corePoolSize is the value below of which executor adds a new thread rather than queuing it maxPoolSize is the value above of which executor

ThreadPoolExecutor parameter configuration

自古美人都是妖i 提交于 2021-02-20 02:29:27
问题 I'm working with a client application which needs to request data from a Rest API. Many of these requests are independent, so they could be called asynchronously. I'm using ThreadPoolExecutor to do so, and I've seen it can be configured with several parameters: corePoolSize maxPoolSize queueCapacity I read this article and I understand the following: corePoolSize is the value below of which executor adds a new thread rather than queuing it maxPoolSize is the value above of which executor

Processing tasks in parallel and sequentially Java

↘锁芯ラ 提交于 2021-02-10 05:35:21
问题 In my program, the user can trigger different tasks via an interface, which take some time to process. Therefore they are executed by threads. So far I have implemented it so that I have an executer with one thread that executes all tasks one after the other. But now I would like to parallelize everything a little bit. i.e. I would like to run tasks in parallel, except if they have the same path, then I want to run them sequentially. For example, I have 10 threads in my pool and when a task

Python ThreadPoolExecutor terminate all threads

假装没事ソ 提交于 2021-01-28 18:16:49
问题 I am running a piece of python code in which multiple threads are run through threadpool executor. Each thread is supposed to perform a task (fetch a webpage for example). What I want to be able to do is to terminate all threads, even if one of the threads fail. For instance: with ThreadPoolExecutor(self._num_threads) as executor: jobs = [] for path in paths: kw = {"path": path} jobs.append(executor.submit(start,**kw)) for job in futures.as_completed(jobs): result = job.result() print(result)

Modify java.util class using byte-buddy-agent

隐身守侯 提交于 2021-01-28 15:07:30
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

Modify java.util class using byte-buddy-agent

旧巷老猫 提交于 2021-01-28 15:05:34
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

Modify java.util class using byte-buddy-agent

白昼怎懂夜的黑 提交于 2021-01-28 15:02:56
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

Modify java.util class using byte-buddy-agent

萝らか妹 提交于 2021-01-28 15:01:00
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

ThreadPoolExcutor and invokeAll list order

北城余情 提交于 2021-01-27 11:29:40
问题 I'm working on ThreadPoolExcutor . I would like to know if in invokeAll method, I can be sure that the output ( Future objects) order is going to be the same as the input ( Callable list). List<Future<T>> invokeAll(List<Callable<T>> tasks) 回答1: What is guaranteed is that the list of futures returned has the same order that the list's iterator you're giving. Note that this method only returns when all tasks have been completed. Quoting invokeAll(tasks) Javadoc: Returns: a list of Futures

ThreadPoolExcutor and invokeAll list order

眉间皱痕 提交于 2021-01-27 11:23:31
问题 I'm working on ThreadPoolExcutor . I would like to know if in invokeAll method, I can be sure that the output ( Future objects) order is going to be the same as the input ( Callable list). List<Future<T>> invokeAll(List<Callable<T>> tasks) 回答1: What is guaranteed is that the list of futures returned has the same order that the list's iterator you're giving. Note that this method only returns when all tasks have been completed. Quoting invokeAll(tasks) Javadoc: Returns: a list of Futures