Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int N = 5000;
- int[] list1 = new int[N];
- int[] list2 = new int[N];
- int total;
- Scanner scan = new Scanner(System.in);
- for (int k = 0; k <= N-1; k++) list1[k] = scan.nextInt();
- for (int k = 0; k <= N-1; k++) list2[k] = scan.nextInt();
- MyRunnable runnable1 = new MyRunnable(list1);
- Thread thread1 = new Thread(runnable1);
- MyRunnable runnable2 = new MyRunnable(list2);
- Thread thread2 = new Thread(runnable2);
- thread1.start();
- thread2.start();
- total = runnable1.getTotal() * runnable2.getTotal();
- System.out.println("total is : " + total);
- }
- }
- //*****************************
- //"MyRunnable" file
- public class MyRunnable implements Runnable{
- private int[] list;
- private int total = 1;
- public MyRunnable(int[] list){
- super();
- this.list = list;
- }
- public int getTotal(){
- return this.total;
- }
- @Override
- public void run() {
- for (int i : this.list) {
- this.total *= i;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement