Advertisement
sergAccount

Untitled

Jan 23rd, 2021
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.app2;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class MyTask implements Runnable {
  13.    
  14.     private int n;
  15.     private int m;
  16.  
  17.     public MyTask(int n, int m) {
  18.         this.n = n;
  19.         this.m = m;
  20.     }
  21.     @Override
  22.     public void run() {        
  23.         int s = 0;
  24.         MyFunction f = new MyFunction();
  25.         for (int i = n; i <=m; i++) {
  26.             s+= f.calc(i);            
  27.         }
  28.         System.out.println(Thread.currentThread().getName() + ": s=" + s);
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement