CodeGym /Java Course /Java Core /Practice sleeping

Practice sleeping

Java Core
Level 6 , Lesson 7
Available

"Hello, Amigo!"

4
Task
Java Core, level 6, lesson 7
Locked
Clocks
Classic Terrian clocks say "tick-tock". And they should sound the same in our program. Figure out what the program does and implement the printTickTock method. In the first half of each second, the method should display "Tick." In the second half of each second, it should display "Tock."
9
Task
Java Core, level 6, lesson 7
Locked
Stopwatch
Implement logic in the doStep method so that the runner's speed is taken into consideration. The Runner class's getSpeed() method displays how many steps per second a runner takes. The runner needs to actually take a specified number of steps per second. If Usain takes 4 steps per second, then he will take 8 steps in 2 seconds. If Carl takes 2 steps per second, then he will take 4 steps in 2 seconds.
9
Task
Java Core, level 6, lesson 7
Locked
Big Ben
"It's midnight in London," says Uncle Ben. Make him speak automatically. Figure out what the program does and implement the printTime method so that the time is given every second, beginning with the time specified in the constructor.
9
Task
Java Core, level 6, lesson 7
Locked
Countdown
1. Figure out what the program does. 2. Implement logic in the printCountdown method so that every half a second the program displays an object from the variable list. The output should be in reverse order: from the index passed to Countdown down to zero. Example: Index 3 is passed Example console o
4
Task
Java Core, level 6, lesson 7
Locked
Airport
1. Figure out what the program does. 2. Correct the takeOff method. It currently takes a looooong time. A takeoff should take 100 milliseconds. 3. Implement the waitForTakeoff method by analogy with the takeOff method. The wait time should not be longer than the takeoff time.
Comments (25)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
matemate123 Level 50, Kraków, Poland
6 January 2023
It's not easy for first time play with Thread class. I spend some time on that five tasks, and after that I need some Thread.sleep(28_800_000).
Oliver Heintz Level 18, Mustang, United States
28 January 2021
Ok, so I understood all of these tasks, and was able to complete them all quite easily. Now I am worried. Usually when this happens, the next set of tasks will be impossible for me to complete without help, and ritualistic suicide seems the only recourse. Oh, CodeGym, how you like to lull us into a false sense of security.
Aleksa Level 18, Belgrade, Serbia
6 April 2022
now get lost
Andrei Level 41
15 December 2020
The Big Ben exercise is quite stupid because it clearly says in the conditions that hours cannot be greater than 23 and minutes and seconds cannot be greater than 59 yet in the solution provided if user introduces 25, or 66 or 93 they are displayed as is. And I spent like a fool over an hour trying to find an algorithm that doesn't allow this when the solution doesn't even take this into consideration... Come on. CodeGym! Get your s**t together !
Michael Brimage Level 19, Washington D.C., United States
23 April 2020

public static void main(String[] args) throws InterruptedException {
        Clock clock = new Clock("London", 23, 59, 57);
        Thread.sleep(4000);
        isStopped = true;
        Thread.sleep(1000);
    }
what is the purpose of the second Thread.sleep() call (line 5) in the exercises?
Andrei Level 41
15 December 2020
To sleep the main method for 1 sec before finishing the program.
Jonaskinny Level 25, Redondo Beach, United States
10 March 2022
to sleep the main Thread for 1 second before finishing the program.
Seb Level 41, Crefeld, Germany
3 February 2020
The Airport example is awesome. There are actually lots and lots of scenarios in which you need multithreading in real world airport and airtraffic control center systems. Pretty neat. :-)
MICHAEL DUNLAP Level 20, Bellevue, United States
7 September 2019
Trick is not to overthink.
Seferi Level 22, United Federation of Planets
11 September 2020
Absolutely agree with that. LESS IS MORE...
matemate123 Level 50, Kraków, Poland
6 January 2023
Definietly true, for me in task Countdown.
Ewerton Level 30, Belo Horizonte, Brasil
2 July 2019
It must be hard to correct someone's code in real life.
JeRiF94 Level 22, Baku, Azerbaijan
21 May 2019
DONE
Darko Jakimovski Level 18, Kriva Palanka, Macedonia, The Former Yugoslav Republic of
20 May 2019
Hoist Level 35, San Diego, United States
13 November 2022
Ya. That.
// Java Poser Level 18, Cincinnati, United States
18 April 2019
The hardest part in these tasks is "Figure out what the program does", no kidding this is very tough for me
Roy Level 22, Bangkok, Thailand
3 May 2019
Happy to read this comment! At least i feel i'm not the only one having this problem , hehe =) Gotta read the code 10 times to see where everything goes and what it does, lol. Time consuming!
Darko Jakimovski Level 18, Kriva Palanka, Macedonia, The Former Yugoslav Republic of
20 May 2019
I turd that notion guys, but that has helped me to understand things much better. And each time there is a similar task it gets easier.
Henk Level 19, Pretoria, South-Africa
24 May 2019
sheesh, my head spins. Will now take a break and continue on Monday, my brain needs to step away and have a break for a day to assimilate/interpret the information...
Nicolas Huet Level 41, Provins, France
26 May 2019
Using the debugger is very helpful in that matter, you can follow the program execution and see how variables, arrays and everythings are used and filled through the execution.
Ed Maphis Level 20, Painesville, United States
12 June 2019
All the programs are doing really is putting objects in a list, running through the list and executing a method on each method. This difference here is each object's methods are running on a thread and your have to use "join" and "sleep" to control the behavoir of the called method.
Durmus Gulbahar Level 22, Antalya, Turkey
28 August 2019
Haha u r right but we need this , you can think this like that when you looking to a image for paint it , first time of painter is start with copy of what he see.
Korlat Level 25, Gasteiz, Basque Country, Spain
25 May 2022
Am I the only one who doesn't know how to use the debugger properly? I never know where to put the breakpoints!
Dawn( #11020889) Level 37, Toronto, Canada
21 October 2022
me either😂
Hoist Level 35, San Diego, United States
13 November 2022
Search for debugger in codegym! -- it's a good section about intelliJ debugging tooling OR HERE >>> https://codegym.cc/quests/lectures/questcollections.level09.lecture03