Wednesday, January 13, 2021

How do you create a thread in Java and run it?

The answer lies in the commands we will use, which are:
Thread.start() and Thread.run() in Java

Reading this with no programming knowledge, it makes sense to say that creating is the start of the exercise and that after it is created/started it will be run. 

These are the most important things to remember when you are multi-threading (or as I like to call it multi-tasking): it's where you are already busy in for example the kitchen (i.e. you are already cooking or running a thread) in my previous post; and you can get the next item ready while you are still stirring away or setting a timer, i.e. filling the kettle with cold water is the step before you can create boiling water and starting it would be when you turn the kettle on. 

Will the kettle stop while you are still stirring your sauce? If you are reliant on Eskom it is anybody's guess but it will mostly stop automatically once temperature is reached.

I love making tables to visually and linguistically demonstrate what we are talking about and it follows below:



No comments:

Post a Comment