C# や Linq のように、Java でクエリを並列化する方法が存在するかどうか (またはフレームワークやライブラリがあるかどうか) を知りたいです。
var query = from item in source.AsParallel().WithDegreeOfParallelism(2)
where Compute(item) > 42
select item;
そして、もし私がC#でこのようなことをすることができればクエリを並列化できない場合(並列化されたものごとに):
Parallel.ForEach(files, currentFile =>
{
// The more computational work you do here, the greater
// the speedup compared to a sequential foreach loop.
string filename = System.IO.Path.GetFileName(currentFile);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(currentFile);
bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
bitmap.Save(System.IO.Path.Combine(newDir, filename));
// Peek behind the scenes to see how work is parallelized.
// But be aware: Thread contention for the Console slows down parallel loops!!!
Console.WriteLine("Processing {0} on thread {1}", filename,
Thread.CurrentThread.ManagedThreadId);
}
フレームワークやライブラリを投稿する場合は、それを使った経験を教えてください。お時間いただきありがとうございます。
C# と linq については、こちらのドキュメントを参照してください: http://msdn.microsoft.com/en-us/library/dd997425.aspx