Start learning now
You've reached Level 25
You've reached Level 25
Enum and all its features
"Hi, Amigo!" "Hi, Amigo!" "I'm going to tell you about something very interesting. It's pretty simple, but that makes it even more interesting. It's called an enum. An enum is a type that defines the specific set of values that a variable can have. Let's look at an example right off ..."
Practice using enum
"Hi, Amigo!" "Bilaabo came up with a task for you. Enjoy, my friend ..."
Thread life cycle and thread states
"Hi, Amigo!" "We're going to start a new topic: threads." "Let's get started. Today we will examine the states that a Thread object passes through (or might pass through) when a thread is running." "How many states can you name right now, Amigo?" "Two. The first is a thread before the start() method is called: the object exists, but the thread isn't active yet. And the second is after the start() method has been called ..."
All the nuances of creating and starting a new thread. Daemons.
"Here's a new and interesting topic." "It turns out you can start threads in different modes." "A standard program (with only one thread) stops running when the main thread finishes its work. The main thread finishes executing, the program terminates, and the JVM frees its memory ..."
Practice with the current thread state
"Hi, Amigo! How are you feeling?" "Excellent. I learned so many new things today. Especially about thread states." "Oh, that's great. Here, let's test your knowledge ..."
All the nuances of interrupting/stopping threads
"Hi, Amigo! "Everything new is just something old that we've forgotten. Today I'll talk about stopping threads. I hope you've already forgotten how the interrupt() method works." "Yes, Ellie, I've completely forgotten it." "Great. Then I'll remind you." "In Java, if someone wants to stop a running thread, he can signal this to the thread. To do this, you need to set the Thread object's hidden isInterrupted variable to true ..."
Practice interrupting threads
"I was just waiting for you. There's so much interesting work for you here ..."
The call stack and catching errors
"Hi, Amigo! "I want to tell you about something small, but interesting." "I'm listening. I love things that are small and interesting." "Well, you know that every Thread object has a run() method. And that you can execute it on a separate thread using the start() method." "Yes, of course." "But now imagine this situation: you start a thread to perform some work, but an exception is thrown and the thread stops running ..."
Practice catching thread errors
"How come you always get exactly 3 tasks?" "How about doing another 50?" "50? O_o" "I guess it would be better to just do the usual 3 ..."
Other methods of the Thread class (sleep, yield…)
"Hi, Amigo!" "Now I'll tell you a little about the sleep, yield, and join methods." "That's boring. I just found an interview question: 'What's the difference between the yield(), sleep(), and wait() methods?'. Can you explain that?" "No problem. First off, these are three completely different methods ..."
Practice using yield and surrendering time slices
"Hi, Amigo! Keep practicing! Here are a couple of tasks for you ..."