Register   Login   About   Study   Enterprise   Share
Internet / AI Technology University (ITU/AITU)
Fast Login - available after registration







|

Top Links: >> 80. Technology >> Internet Technology Summit Program >> 3. Threads and Network
Current Topic: 3.1. Threads
Sub-Topics: 3.1.1. Thread and Runnable Examples | 3.1.2. Threads in graphics and game. | 3.1.3. Using ThreadGroup | 3.1.4. Thread Safety
-- Scroll to check for more content below...
You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
What is a thread?

An independent sequence of execution is a thread.
A single process, more precisely, a light weight process is a thread.
Timer or I/O operation can be considered as an example of threads.

What is multi-threaded environment?

It is when more than just one thread is allowed to run on the machine.
Java Virtual Machine (JVM) is such an environment simultaneously running multiple applications or multiple parts of a single application.

Threads in Java

Java gives us ability to use threads in application design.
Threads are defined by Java Spec as a part of standard library, and the class Thread class is defined in the java.lang.* package as an implementation of the Runnable interface.

There are two basic ways to create a Thread: use the Thread class and extend into your own class or create your class that implements Runnable interface and pass the object of this class to a thread constructor.
Was it clear so far?


The last method is preferable as implementing interface has less limitations.

In both cases we get the Thread object and use the method thread.start() to start the thread.


Even if you don't include threads into your design, Java VM internals can use threads on its own for example for garbage collection, painting windows or getting images.

Using Threads

Here is a scenario of using threads in our life.

You need to travel overseas. Do you have a valid passport? Oh no! The passport has expired. The first thing is to renew the passport. This process involves several actions on your behalf and then a government action. You start this process, do your portion and wait for the government.

This can take several days or even weeks. You do not sit idle. After you started this process you can do other things while periodically checking your mail box.

In this scenario passport renewal is one thread, which will be continued till your passport finds you. At the same time you perform other things. Think of them as other threads.
| Check Your Progress | Propose QnA | Have a question or comments for open discussion?

Have a suggestion? - shoot an email
Looking for something special? - Talk to me
Read: IT of the future: AI and Semantic Cloud Architecture | Fixing Education
Do you want to move from theory to practice and become a magician? Learn and work with us at Internet Technology University (ITU) - JavaSchool.com.

Technology that we offer and How this works: English | Spanish | Russian | French

Internet Technology University | JavaSchool.com | Copyrights © Since 1997 | All Rights Reserved
Patents: US10956676, US7032006, US7774751, US7966093, US8051026, US8863234
Including conversational semantic decision support systems (CSDS) and bringing us closer to The message from 2040
Privacy Policy