Se quiere implementar un monitor Java que proporcione la funcionalidad básica del CountDownLatch, con los métodos countDown y await.public class MiCountDownLatch { private int n; public MiCountDownLatch(int n0) { n=n0; } public synchronized void countDown() { n--; notifyAll(); } public void await() throws InterruptedException { while (n > 0) wait(); }}Preguntas 14 de 20 0,5 Puntos. Puntos descontados por fallo: 0.25Esta solución no es correcta porque se pueden producir condiciones de carrera.VerdaderoFalsoBorra selecciónPreguntas 15 de 20 0,5 Puntos. Puntos descontados por fallo: 0.25Con esta solución, como el valor del contador de la barrera podría ser negativo, se podrían quedar hilos suspendidos al hacer await sobre la barrera, aunque la barrera esté ya abierta.VerdaderoFalsoBorra selecciónPreguntas 16 de 20 0,5 Puntos. Puntos descontados por fallo: 0.25Para que esta solución sea correcta hay que sustituir en el método countDown la línea actual de notifyAll() por signalAll().VerdaderoFalso
Question
Se quiere implementar un monitor Java que proporcione la funcionalidad básica del CountDownLatch, con los métodos countDown y await.public class MiCountDownLatch { private int n; public MiCountDownLatch(int n0) { n=n0; } public synchronized void countDown() { n--; notifyAll(); } public void await() throws InterruptedException { while (n > 0) wait(); }}Preguntas 14 de 20 0,5 Puntos. Puntos descontados por fallo: 0.25Esta solución no es correcta porque se pueden producir condiciones de carrera.VerdaderoFalsoBorra selecciónPreguntas 15 de 20 0,5 Puntos. Puntos descontados por fallo: 0.25Con esta solución, como el valor del contador de la barrera podría ser negativo, se podrían quedar hilos suspendidos al hacer await sobre la barrera, aunque la barrera esté ya abierta.VerdaderoFalsoBorra selecciónPreguntas 16 de 20 0,5 Puntos. Puntos descontados por fallo: 0.25Para que esta solución sea correcta hay que sustituir en el método countDown la línea actual de notifyAll() por signalAll().VerdaderoFalso
Solution 1
Pregunta 14: Falso. No hay condiciones de carrera porque los métodos están sincronizados.
Pregunta 15: Falso. El valor del contador no puede ser negativo porque el método countDown solo decrementa el contador si es mayor que cero.
Pregunta 16: Falso. En Java, el método correcto para despertar a todos los hilos que están esperando es notifyAll(), no signalAll().
Solution 2
Pregunta 14: Falso. No hay condiciones de carrera en este código porque los métodos están sincronizados.
Pregunta 15: Falso. El valor del contador no puede ser negativo porque el método countDown solo decrementa el contador si es mayor que cero.
Pregunta 16: Falso. En Java, el método correcto para despertar a todos los hilos que están esperando es notifyAll(), no signalAll().
Solution 3
Pregunta 14: Falso. No hay condiciones de carrera en este código porque los métodos están sincronizados, lo que significa que solo un hilo puede ejecutarlos a la vez.
Pregunta 15: Falso. El valor del contador no puede ser negativo porque el método countDown solo decrementa el contador si es mayor que cero.
Pregunta 16: Falso. En Java, el método correcto para despertar a todos los hilos que están esperando es notifyAll(), no signalAll().
Similar Questions
What is the purpose of the CountDownLatch class in Java threads? Question 3Answera.It Delays the execution of a thread.b.It Counts the number of active threads in the program.c.It synchronizes the execution of multiple threads till the operations are complete.d.Allows one or more threads to wait for a set of operations to complete.
evelop a Java program that simulates a simple countdown timer usingmultithreading. The program should allow users to start multiple timersconcurrently, each running independently and provide its sample input,output
Develop a Java program that creates a GUI application for a stopwatch usingSwing. The stopwatch should have start, stop, and reset buttons, and displaythe elapsed time.
Countdown is trialling security cameras at self-checkouts to prevent theft.The technology, which is being trialled at five stores across the country, records the shopper and the transaction and detects when items aren’t scanned correctly.The trial was being conducted to test the accuracy of the checkout process and new stock loss prevention technology, a sign in a Wellington Countdown read.ADVERTISINGThe behaviour-based technology monitors product movement during the checkout process and can see when the product has been picked up, scanned and bagged and would help reduce mis-scanned items at the self-checkout.More from Stuff:* Auckland food importers fined $28k for failing to label food allergens properly on products* Second measles case in the span of one week detected in Auckland* Peter FitzSimons calls for Robbie Deans to replace Eddie Jones after Wallabies' World Cup crashA camera would be focused on each self-service checkout, while another camera pointed down on the checkout from above.A Countdown spokesperson said that the video feed was angled to capture the checkout scanning area and faces detected in the video were blurred using artificial intelligence. Pinpads were also blacked out.ADVERTISEMENTAdvertise with StuffPauseUnmuteCurrent Time 0:04/Duration 0:15Loaded: 0% FullscreenRICKY WILSON/STUFFCountdown introduces new AI shopping technology.“We have strict security policies in place to protect customer privacy, and the footage captured is handled similarly to CCTV.“If a misscan occurred, a short video highlighted the affected product and customers could then re-scan.The footage is then automatically deleted after 30 days unless it is required to support an investigation.Customers who did not want to be part of the trial could use express checkouts.The spokesperson did not say how long the trial would run for but said the supermarket would “listen closely to feedback as we continue to introduce this technology over the coming months”.The trial comes three years after Countdown introduced Picklist Assist, an image recognition technology that was able to detect the type of loose produce a customer was purchasing, making it difficult to scan a more expensive item as something cheaper.Foodstuffs, which owns Pak’nSave and New World stores, had also been testing a number of theft prevention tactics after it experienced a nearly 40% increase in retail crime from the February to April quarter this year compared to last.KEVIN STENT/STUFFAnti-theft techonolgy has been used at self-checkouts before.Serious incidents such as burglary, assault, robbery, and other aggressive, violent, and threatening behaviour were up 36%.Pak’nSave Cameron Rd in Tauranga had been trialling the use of body cameras on staff, as well as facial recognition technology (FRT).FRT involves the identification of a person based on an analysis of their facial features. Artificial intelligence programmes identify and map facial features to create a face print, which is compared to those on a database to find a match.ADVERTISEMENTAdvertise with StuffIt also had CCTV cameras, uniformed and plain-clothed security team members and staff training to de-escalate situations.
Design a four-bit binary synchronous countdown counter with JK flip-flops.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.