Module6_Chapter1_Core Java
Module6_Chapter1_Core Java
MANUAL V8.3
MODULE CODE:
DL.A.01.01
ANUDIP FOUNDATION
Trainer
Manual Core Java
1
Trainer
Manual Core Java
Chapter 1
2
Trainer
Manual Core Java
Chapter 1
A thread in Java is a flow of control within a program. The java.lang.Thread class is used for generating and
i) Threading
Threading deals with the management and execution of Java threads within programs. Programmers can perform
threading to execute single or multi-threads, based on the requirements of a program. A single thread executes a
single threading within a process. If many tasks need to be run at the same time, using multiple threads is ideal.
Multiple threads are used for multiple threading of processes. Multithreading is necessary if two or more tasks are to
be run simultaneously within a Java process. Each thread in a multithreaded process might be assigned different tasks.
They can perform their specified tasks at the same time alongside the other threads, or at different times, or at
intervals. Multithreading can also be explained as multiple threads within a process executing byte-code instructions.
System.out.println("multiple thread");
}
public static void main(String args[]){
3
Trainer
Manual Core Java
t1.start();
}
}
* Processes take more time to create and destroy, while threads take less time to both create and destroy.
* Processes are known as heavyweight tasks, while threads are known as lightweight tasks.
See the example programme for Java multithreading below. Write the same programme to show multithreading for
the string “multi threads”. Show the resulting output. Repeat the same programme for the string “thread
multiple”
System.out.println("multiple thread");
t1.start();
4
Trainer
Manual Core Java
5
Trainer
Manual Core Java
Instructions: The progress of students will be assessed with the exercises mentioned below.
a) control
b) commands
c) controllers
a) Java.lang.Thread
b) Java.lang
c) Java.util
3. If a programmer must create a program where two tasks run simultaneously, he will choose _______________.
a) multi threading
b) single threading
c) both a and b
6
Trainer
Manual Core Java
a) different
b) only identical
c) rejected
a) No
b) Yes
c) Very rarely
a) bit-code
b) byte-code
c) both a and b
a) No
b) sometimes
7
Trainer
Manual Core Java
a) process
b) thread
c) sub-thread
a) yes
b) no
c) only sometimes
a) base weight
b) heavyweight
c) lightweight