Skip to content

Instantly share code, notes, and snippets.

@krthkj
krthkj / Assignment101.java
Last active Jun 5, 2020
Multi-Thread code - Value of Pi - Monte Carlo
View Assignment101.java
// Estimate the value of Pi using Monte-Carlo Method, using sequential program
package assignments;
public class Assignment101 {
public static void main(String[] args) {
int nThrows = 100000;
long startTime = System.currentTimeMillis();
double x = 0, y = 0;
int nSuccess = 0;
for (int i = 1; i <= nThrows; i++) {
x = Math.random();