Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hey there , how are you , i hope that you're doing well could u please solve this assignment for me in java

hey there , how are you , i hope that you're doing well could u please solve this assignment for me " in java " ? the assignment wants to create 8 threads , and each thread should generate 12,500,000 point in this shape that i sent ! so we want to see how many points generated in the cyrcle , and how many points generated in the square and get value ! = 4 (number of points in circle) / (total number of points) and last but not least i want you to use mutex to determine how many threads and avoid race condition ! i will be greatfull for u!

image text in transcribed

Using Java, write a computer program that solves the following problem: An interesting way of calculating n is to use a technique known as Monte Carlo, which involves randomization. This technique works as follows: Suppose you have a circle inscribed within a square, as shown in Figure 1. (-1, 1) (1,1) (0,0) (-1,-1) (1,-1) Figure 1. Monte Carlo technique for calculating Pl. (Assume that the radius of this circle is 1.) First, generate a series of random points as simple (x, y) coordinates. These points must fall within the Cartesian coordinates that bound the square. Of the total number of random points that are generated, some will occur within the circle. Next, estimate n by performing the following calculation: 1 = 4x (number of points in circle) / (total number of points) Write a multithreaded version of this algorithm that creates several threads (8 threads), each of which generates random points (12,500,000 points) and determines if the points fall within the circle. Each thread will have to update the global count of all points that fall within the circle. Protect against race conditions on updates to the shared global variable by using mutex locks. When all threads have exited, the parent thread will calculate and output the estimated value of t. It is worth experimenting with the number of random points generated. As a general rule, the greater the number of points, the closer the approximation to n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

6. Describe why communication is vital to everyone

Answered: 1 week ago