Sawan Mishra wrote:do1() is completed by both threads in 1 sec
and as do2() is synchronized so its executed
one after the other thus both together should
take 2 sec so total 3 sec lapsed
Steve
Ramesh-X
Ramesh Pramuditha Rathnayake wrote:Think there is only one thread. And then it takes 8 seconds to finish the job.
We can assume that both threads start simultaneously. Therefore do1() is run by both threads simultaneously and it takes 1 sec to run by both threads. As do2() is synchronized it takes 2 sec to run by both threads. And that means to execute one cycle it takes 3 seconds.
Answer => 3x4=12 seconds
There are three kinds of actuaries: those who can count, and those who can't.
In this case: what's wrong with answer B? If something runs in about 9 seconds, then surely its mimimum time
is 8 seconds (or 7, or ...)?
There are three kinds of actuaries: those who can count, and those who can't.
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|