Parallel programming in Java

2019-03-08 05:23发布

How can we do Parallel Programming in Java? Is there any special framework for that? How can we make the stuff work?

I will tell you guys what I need, think that I developed a web crawler and it crawls a lot of data from the internet. One crawling system will not make things work properly, so I need more systems working in parallel. If this is the case can I apply parallel computing? Can you guys give me an example?

19条回答
啃猪蹄的小仙女
2楼-- · 2019-03-08 06:11

Short answer with example library

If you are interested in parallel processing using Java, I would recommend you to give a try to Hazelcast Jet.

No more words needed from my side. Just check the website and learn by their examples. It give you pretty solid background and imagination about what does it meen to process data paralelly.

https://jet.hazelcast.org/

查看更多
祖国的老花朵
3楼-- · 2019-03-08 06:12

Java supports threads, thus you can have multi threaded Java application. I strongly recommend the Concurrent Programming in Java: Design Principles and Patterns book for that:

http://java.sun.com/docs/books/cp/

查看更多
SAY GOODBYE
4楼-- · 2019-03-08 06:14

You might try Parallel Java 2 Library.

On the website Prof. Alan Kaminsky wrote:

Fast forward to 2013, when I started developing PJ2. Parallel computing had expanded far beyond what it was a decade earlier. Multicore parallel computers were equipped with many more CPU cores and much larger main memory, such that computations that used to require a whole cluster now could be done on a single multicore node. New kinds of parallel computing hardware had become commonplace, notably graphics processing unit (GPU) accelerators. Cloud computing services, such as Amazon's EC2, allowed anyone to run parallel programs on a virtual supercomputer with thousands of cores. New application areas for parallel computing had opened up, notably big data analytics. New parallel programming APIs had arisen, such as OpenCL and NVIDIA Corporation's CUDA for GPU parallel programming, and map-reduce frameworks like Apache's Hadoop for big data computing. To explore and take advantage of all these trends, I decided that a completely new Parallel Java 2 Library was needed.

In early 2013 when PJ2 wasn't yet available (although an earlier version was), I tried Java Parallel Processing Framework (JPPF). JPPF was okay but at first glance PJ2 looks interesting.

查看更多
别忘想泡老子
5楼-- · 2019-03-08 06:16

Have you looked at this:

http://www.javacodegeeks.com/2013/02/java-7-forkjoin-framework-example.html?ModPagespeed=noscript

The Fork / Join Framework?

I am also trying to learn a bit about this.

查看更多
冷血范
6楼-- · 2019-03-08 06:17

You want to look at the Java Parallel Processing Framework (JPPF)

查看更多
在下西门庆
7楼-- · 2019-03-08 06:17

Is the Ateji PX parallel-for loop what you're looking for ? This will crawl all sites in parallel (notice the double bar next to the for keyword) :

for||(Site site : sites) {
  crawl(site);
}

If you need to compose the results of crawling, then you'll probably want to use a parallel comprehension, such as :

Set result = set for||{ crawl(site) | Site site : sites }

Further reading here : http://www.ateji.com/px/whitepapers/Ateji%20PX%20for%20Java%20v1.0.pdf

查看更多
登录 后发表回答