Stack-Repo
/
data
/train
/akash-coded
/FSD_Java
/Lesson-3
/Concurrency and Multithreading
/Examples
/FindSumOfNumbers.java
/** | |
* FindSumOfNumbers will count the sum of the number from 1 to the parameter | |
* countUntil and then write the result to the console. | |
* | |
* FindSumOfNumbers is the task which will be performed | |
* | |
* @author Akash Das | |
* | |
*/ | |
public class FindSumOfNumbers implements Runnable { | |
private final long countUntil; | |
FindSumOfNumbers(long countUntil) { | |
this.countUntil = countUntil; | |
} | |
public void run() { | |
long sum = 0; | |
for (long i = 1; i < countUntil; i++) { | |
sum += i; | |
} | |
System.out.println(sum); | |
} | |
} |