What are the benefits of Java – lambda expressions for multi-core systems?
•
Java
Java tutorials of lambda expressions say:
My question is, according to multi-core systems and parallel / parallel programming, what are the specific advantages of lambda expressions?
Solution
Parallelism is negligible If you have a collection and you implement a lambda:
collection.map { // my lambda }
Then the collection itself can parallel this operation without making your own thread, etc Parallelism is handled in the collection map () implementation
In a purely functional (i.e. no side effects) system, you can do this for each lambda For non purely functional environments, you must choose a Lambdas that works in this way (because your Lambdas may not run in parallel) For example, in Scala, you must explicitly adopt parallel view on a collection to achieve the above
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码