久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 久久精品99| 国产精品久久久久久模特 | 欧美成人手机视频 | 日韩色综合 | 免费成人国产 | 免费观看一级毛片 | 中文字幕在线视频网站 | 99精品欧美一区二区三区 | 中国一级特黄毛片大片 | 国产欧美一区二区三区在线看蜜臀 | 久久成人一区 | 欧美成人精品激情在线观看 | 久草新在线| 羞羞视频在线观看 | 三级黄色大片网站 | 国产欧美精品一区二区色综合朱莉 | 超碰最新在线 | 国产亚洲精品精品国产亚洲综合 | 精品国产一区二区三区性色av | 日本不卡免费新一二三区 | 国产日韩精品一区 | 青青草网站在线观看 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 国产成人一区二区三区 | 欧美日韩国产在线 | 国产精品视频免费播放 | 激情五月婷婷在线 | 亚洲高清av | 日韩中文字幕在线播放 | 久久久精品一区二区 | 男女爱爱网站 | 亚洲成人一区二区在线 | 亚洲精品v日韩精品 | 国产专区免费 | 日本成人福利视频 | 在线看91 | 伊人久久在线 | 国产日韩欧美在线观看 | 国产精品视频在线观看 | 国产精品爱久久久久久久 | 韩日一区二区三区 |