Assuming 10 seconds is enough time for all of the tasks to finish, what is the output
Question:
Assuming 10 seconds is enough time for all of the tasks to finish, what is the output of the following application?
A. 0
B. 125
C. -125
D. The code does not compile.
E. The result is unknown until runtime.
F. An exception is thrown.
Transcribed Image Text:
import java.util.concurrent.*; public class Bank { static int cookies = 0; public synchronized void deposit(int amount) { cookies += amount; } public static synchronized void withdrawal (int amount) { cookies amount; } public static void main(String[] amount) throws Exception { var teller= Executors.newScheduled ThreadPool (50); Bank bank = new Bank (); for (int i-0; i <25; i++) { teller.submit(() -> bank.deposit (5)); teller.submit(() -> bank.withdrawal (5)); } teller.shutdown(); teller.awaitTermination (10, TimeUnit. SECONDS); System.out.print(bank.cookies); } }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (3 reviews)
The code provided creates a simple threadsafe banking application using a Bank class with two synchr...View the full answer
Answered By
Nyron Beeput
I am an active educator and professional tutor with substantial experience in Biology and General Science. The past two years I have been tutoring online intensively with high school and college students. I have been teaching for four years and this experience has helped me to hone skills such as patience, dedication and flexibility. I work at the pace of my students and ensure that they understand.
My method of using real life examples that my students can relate to has helped them grasp concepts more readily. I also help students learn how to apply their knowledge and they appreciate that very much.
4.00+
1+ Reviews
10+ Question Solved
Related Book For
OCP Oracle Certified Professional Java SE 11 Developer Practice Tests Exam 1Z0 819 And Upgrade Exam 1Z0 817
ISBN: 9781119696131
1st Edition
Authors: Scott Selikoff, Jeanne Boyarsky
Question Posted:
Students also viewed these Computer science questions
-
Assuming 10 seconds is enough time for all of the tasks to finish, what statements about the following program are correct? (Choose two.) A. The code does not compile. B. The incrementBy10() method...
-
The following program simulates flipping a coin an even number of times. Assuming five seconds is enough time for all of the tasks to finish, what is the output of the following application? A. false...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
To some U.S. manufacturers and labor unions, a cheap yuan value gives China's advantage in the global economy. bankers exports importers subsidies an unfair
-
The process described in Problem 2.11 is a nuclear reaction because it involves changes in the nucleus. Is it nuclear fusion or nuclear fission?
-
Jane Hull Company paid $135,000 for a machine in 2005. The Accumulated Depreciation account has a balance of $46,500 at the present time. The company could sell the machine today for $150,000. The...
-
Suppose you work at Microsoft in its Xbox video game console division. Microsoft has long targeted Xbox to the advanced economies, especially in North America and Europe. Management would like to...
-
Pool Corporation, Inc., reported in its recent annual report that In 2010, our industry experienced some price deflation. . . . In 2011, our industry experienced more normalized price inflation of...
-
The stockholders equity accounts of Flint Corporation on January 1, 2017, were as follows. Preferred Stock (8%, $100 par noncumulative, 5,000 shares authorized) $300,000 Common Stock ($4 stated...
-
What is the output of the following application? A. true B. false C. The code does not compile. D. The result is unknown until runtime. E. An exception is thrown. F. None of the above. import...
-
Which ExecutorService method guarantees all running tasks are stopped in an orderly fashion? A. shutdown() B. shutdownNow() C. halt() D. shutdownAndTerminate() E. None of the above.
-
The probability that an offspring is heterozygous is 0.2.
-
As of June 30, 2012, the bank statement showed an ending balance of \(\$ 13,879.85\). The unadjusted Cash account balance was \(\$ 13,483.75\). The following information is available: 1. Deposit in...
-
An engineering study has developed the following cost data for the production of product A: (1) If the current production level is 1,500 units, what is the incremental cost of producing an additional...
-
On December 1, a group of individuals formed a corporation to establish the Local, a neighborhood weekly newspaper featuring want ads of individuals and advertising of local firms. The free paper...
-
Design an arithmetic circuit with one selection variable S and two n-bit data inputs A and B. The circuit generates the following four arithmetic operations in conjunction with the input carry C in ....
-
For the system you chose for Problems and Exercises 3, complete section 4.0, A-C, Management Issues, of the BPP Report. Why might people sometimes feel that these additional steps in the project plan...
-
An argument could be advanced that some job design methods, including those involving industrial engineering, have led to employees being "deskilled" and "alienated from their work." Debate this...
-
A glass manufacturer produces hand mirrors. Each mirror is supposed to meet company standards for such things as glass thickness, ability to reflect, size of handle, quality of glass, color of...
-
Mention the three auxiliary protocols at the network layer of the TCP/IP suite that are designed to help the IPv4 protocol.
-
In Figure 19.4, show how the sum, wrapped sum, and checksum can be calculated when each word (16 bits) is created instead of waiting for the whole packet to be created. Figure 19.4 Example of...
-
In an IPv4 datagram, the value of the header-length (HLEN) field is (6) 16 . How many bytes of options have been added to the packet?
-
Saly paid $52,000 a year paid on a weekly basis. last pay she had $250 withheld in Income Tax, $48.97 for CPP and $15.80 for EI. an additional $and 25.00 in tax are deducted each pay. She allowed to...
-
Required information [The following information applies to the questions displayed below.] Dain's Diamond Bit Drilling purchased the following assets this year. Asset Drill bits (5-year) Drill bits...
-
Which of the following partnership items are not included in the self-employment income calculation? Ordinary income. Section 179 expense. Guaranteed payments. Gain on the sale of partnership...
Study smarter with the SolutionInn App