tam*_*jar 5 java parallel-processing performance multithreading multiprocessing
所以我有一个函数,它可以在如下所示的大型未排序数字数组中找到一个大于 N 的数字。
import java.util.*;
public class program {
// Linear-search function to find the index of an element
public static int findIndex(int arr[], int t)
{
// if array is Null
if (arr == null) {
return -1;
}
// find length of array
int len = arr.length;
int i = 0;
// traverse in the array
while (i < len) {
// if the i-th element is t
// then return the index
if (arr[i] > t) {
return i;
}
else {
i = i + 1;
}
}
return -1;
}
// Driver Code
public static void main(String[] args)
{
int[] my_array = { 5, 4, 6, 1, 3, 2, 7, 8, 9 };
int i = findIndex(my_array, 7);
// find the index of 5
System.out.println("Index position of 5 is: "
+ my_array[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
但我必须找到一种方法来并行实现这一点。我不确定如何开始或做什么,因为我在并行编程领域还很陌生。
任何帮助将不胜感激。
| 归档时间: |
|
| 查看次数: |
211 次 |
| 最近记录: |