What is the most likely result of executing the following application? A. A deadlock is produced at
Question:
What is the most likely result of executing the following application?
A. A deadlock is produced at runtime.
B. A livelock is produced at runtime.
C. The application completes successfully.
D. The code does not compile.
E. The code hangs indefinitely at runtime.
F. The output cannot be determined ahead of time.
Transcribed Image Text:
package jokes; import public class Riddle { } public void sleep () { try {Thread.sleep (5000); } catch (Exception e) {} java.util.concurrent.*; } public String getQuestion (Riddle r) { synchronized { sleep(); } } } public synchronized String getAnswer (Riddle r) { } if(r = null) r.getAnswer (null); return "How many programmers does it take " + "to change a light bulb?"; sleep(); if(r = null) r.getAnswer (null); return "None, that's a hardware problem"; public static void main(String... ununused) { var r1 = new Riddle(); var r2 = new Riddle (); var s = Executors.newFixedThreadPool (2); s.submit(() > r1.getQuestion (r2)); s.execute(() > r2.getAnswer (r1)); s.shutdown();
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (2 reviews)
The most likely result of executing the application is E The code hangs indefinitely at runtime Here...View the full answer
Answered By
Mishark muli
Having any assignments and any other research related work? worry less for I am ready to help you with any task. I am quality oriented and dedicated always to produce good and presentable work for the client once he/she entrusts me with their work. i guarantee also non plagiarized work and well researched work to give you straight As in all your units.Feel free to consult me for any help and you will never regret
4.70+
11+ Reviews
37+ 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
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
ttth Suppose that the sequence of bags {Bn | n N} is recursively enumerated by the computable function e(n, x) = fn(x), [7 marks] Hence prove that the set of all recursive bags cannot be recursively...
-
pop T3 is taken. Give definitions for offset and delay, and compute both for each set of timestamps. Which of the two offsets you have computed would you prefer to use to adjust the time at C, and...
-
1. Using a diagram of utility maximization, show: a. The income effect of price change b. The substitution effect of price change
-
How can you link "The Response of Slaves" to "Anti-Slavery and French Revolution"? What was the response of slaves? What effect might "Response" have on the slave rebellion in Saint Domingue?
-
In the face-milling operation shown below the cutter is 1.5 inches in diameter and the cast iron workpiece is 7.0 inches long and 3.75 inches wide. The cutter has 8 teeth and rotates at 350 RPM. The...
-
In April 2000 the G4 !1 Group acknowledged that market exit value is generally regarded as the basis for fair value measurement of financial instruments and was discussing the use of the deprival...
-
Prepare common-sized balance sheets and income statements for Just for Feet for the period 19961998. Also compute key liquidity, solvency, activity, and profitability ratios for 1997 and 1998. Given...
-
For ABC, a 18,b-3 and c-20. Find mA to the nearest tenth.
-
Which ScheduledExecutorService method can result in the same action being executed by two threads at the same time? A. scheduleAtFixedDelay() B. scheduleAtFixedRate() C. scheduleWithFixedDelay() D....
-
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 list gives the number of degrees of freedom and the test statistic for several goodness-of-fit tests. Find the P-value for each test as specifically as possible from Statistical Table...
-
The standard cost of product 777 includes 2.4 units of direct materials at $5.20 per unit. During August, the company bought 28,400 units of materials at $5.45 and used those materials to produce...
-
A thin rectangular plate laying on the x-y plane has edge sizes AB = 1 m AB = 2m and thickness t = 0.01 m. The plate is under a distributed transverse load, along the z axis. The plate Young modulus...
-
Question 5. A first responder drone of mass m slug is launched with a velocity vo ft/sec and constant engine force F from a level ground and moves vertically upward to discover a sense of life in a...
-
SunnyVale Trailer Park has a free cash flow of $500 000. The company pays a 30% tax rate. Interest on debt, which accounts for 40% of its capital structure, is 6%. The beta for its common stock is...
-
Carter Containers sold marketable equity securities, land, and common stock for $30 million, $15 million, and $40 million, respectively. Carter also purchased treasury stock, equipment, and a patent...
-
The following activities are common at Pisanas Department Store. Goods are received with barcodes attached that can be read by scanners but not by customers. 1. Attending trade shows to view new...
-
Banner Company acquires an 80% interest in Roller Company for $640,000 cash on January 1, 2013. The NCI has a fair value of $160,000. Any excess of cost over book value is attributed to goodwill. To...
-
OSPF messages and ICMP messages are directly encapsulated in an IP datagram. If we intercept an IP datagram, how can we tell whether the payload belongs to OSPF or ICMP?
-
Use Dijkstra's algorithm (Table 20.2) to find the shortest path tree and the forwarding table for node A in the Figure 20.35. Table 20.2 4. 4. 3. 3.
-
OSPF messages are exchanged between routers. Does this mean that we need to have OSPF processes run all the time to be able to receive an OSPF message when it arrives?
-
Canon Industries has gathered the following information about the actual sales revenues and expenses for its pharmaceuticals segment for the most recent year. (Click the icon to view the actual...
-
Lean Accounting The annual budgeted conversion costs for a lean cell are $180,000 for 1,000 production hours. Each unit produced by the cell requires 20 minutes of cell process time. During the...
-
Month Ended December 31, 2016 V flows from operating activities eipts: Collections from customers' yments: For rent For utilities -1400 -80 4800 For salaries -1200 et cash provided (used) by...
Study smarter with the SolutionInn App