Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@krthkj
krthkj / Assignment101.java
Last active August 31, 2023 18:45
Multi-Thread code - Value of Pi - Monte Carlo
// 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();