久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Python pool.map/Multiprocessing 的 Java 等效項

Java equivalent for Python pool.map/ Multiprocessing(Python pool.map/Multiprocessing 的 Java 等效項)
本文介紹了Python pool.map/Multiprocessing 的 Java 等效項的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想知道是否有人可以指出我在 java 中的一個簡單等效的 python 多處理模塊.

I was wondering if somebody could point me to a simple equivalent of python's multiprocessing module in java.

我有一個簡單的并行處理場景(其中沒有 2 個進程交互):獲取一個數據集并將其拆分為 12 個并將 java 方法應用于 12 個數據集,收集結果并將它們加入某種列表中相同的順序.

I have a simple parallel processing scenario (where no 2 processes interact): Take a data set and split it into 12 and apply a java method to the 12 datasets, collect results and join them in a list of some sort with the same ordering.

作為專業"語言的 Java 似乎有多個庫和方法 - 誰能幫助這個 Java 新手入門?

Java being a "pro" language appears to have multiple libraries and methods - anyone who can help this java newbie get started?

我想用最少的代碼來做這件事 - 正如我所說的,我的要求非常簡單.

I would like to do this with minimal of coding - as i said my requirement is pretty straightforward.

更新:如何在 java 中進行多處理,以及預計速度會提高多少?

這似乎表明線程是要走的路.我希望我別無選擇,只能涉入一堆船閘(雙關語無意)并等待我的船航行.盡管如此,還是歡迎簡單的例子.

This seems to indicate threads is the way to go. I expect I have no choice but wade into a bunch of locks (pun unintended) and wait for my ship to sail. Simple examples are welcome nevertheless.

推薦答案

沒有完全兼容的類,但是 ExecutorService 為您提供實現它所需的一切.

There's no exactly-compatible class, but ExecutorService gives you everything you need to implement it.

特別是,沒有將 Callable 映射到 Collection 并等待結果的函數,但您可以輕松構建 Collection<Callable<T>>Callable<T>Collection,然后只需調用 invokeAll,它會返回一個列表<未來<T>>.

In particular, there's no function to map a Callable over a Collection and wait on the results, but you can easily build a Collection<Callable<T>> out of a Callable<T> and Collection<T>, then just call invokeAll, which returns you a List<Future<T>>.

(如果您想模擬 multiprocessing.Pool 中的一些其他函數,則需要循環 submit 并構建自己的等待集合開.但是map很簡單.)

(If you want to emulate some of the other functions from multiprocessing.Pool, you will need to loop around submit instead and build your own collection of things to wait on. But map is simple.)

這篇關于Python pool.map/Multiprocessing 的 Java 等效項的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 一区二区三区免费网站 | 日韩一区二区三区在线播放 | 亚洲国产精品成人久久久 | 国产一区二区免费 | 狠狠狠色丁香婷婷综合久久五月 | 中文字幕电影在线观看 | 久久tv在线观看 | 成人二区 | 国产成人综合在线 | 一区二区三区视频免费观看 | 国产情侣一区 | 一区二区三区在线播放 | 中文字幕 国产 | 日韩在线欧美 | 亚洲高清成人在线 | 久青草影院 | 久久久久久中文字幕 | 亚洲综合在线视频 | 草草网| 国产精品18久久久久久久 | 亚洲三级av| 久久久久91 | 国产高清视频在线观看 | 婷婷丁香综合网 | 黄色大片毛片 | 国产不卡在线 | 美女天天操| 天堂一区 | 丝袜天堂 | 日韩电影一区 | 午夜精品视频在线观看 | h视频在线免费看 | 亚洲永久免费观看 | 成人高清在线视频 | а天堂中文最新一区二区三区 | 国产一区二区三区在线看 | 日韩精品 电影一区 亚洲 | 午夜影院操 | 久久久九九九九 | m豆传媒在线链接观看 | 亚洲综合久久久 |