Learn
Congratulations on completing this lesson on threading! So far, you have:
- created threads in three different ways:
- extending the
Thread
class - implementing the
Runnable
class - using the in-line, lambda expression syntax
- extending the
- started threads with
.start()
- paused the execution of threads using
Thread.sleep(long millis)
- observed thread execution using the supervisor pattern
- blocked on thread completion with
.join()
- synchronized access to shared resources from threads with the
synchronized
keyword - communicated between threads with
.wait()
and.notify()
That’s a lot to have covered!
You can now use threading to solve many intermediate and advanced problems when programming with Java. Try to think of more examples like the FortuneTeller
or CakeMaker
classes, that help to perform multiple tasks at the same time.
Instructions
Take a look at your CakeMaker
class, what improvements would you like to make? Play around with the code and see what you can do.
Remember the four principles of Object-Oriented Programming: Inheritance, Polymorphism, Abstraction, and Encapsulation, we left plenty of room to improve in those areas.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.