eProgrammingLab

Java


1.	What is thread?
•	A thread is similar to a program that has a signal flow of control.
•	A thread has a beginning, a body, and an end; and executes commands sequentially.
•	Each thread is a statically ordered sequence of instructions.
•	Threads are being extensively used express concurrency on both single and multiprocessor machines.
•	JVM by default executes main thread. Whatever methods and variables are called in main method, it executes sequentially.
2.	What is multithreading?
Multithreading is the ability of a program or an operating system process to manage its use by more than one user at a time and to even manage multiple requests by the same user 
without having to have multiple copies of the programming running in the computer. 3. What are thread methods? Java has builtin thread support for multithreading. These are: CurrentThread, yield, sleep, resume, start, run, stop, setPriority, getPriority, suspend. 4. What is thread declaration? Thread can be declared in two wyas: • Create a class that extends the Thread class (Thread is super class). • Create a class that implements the Runnable interface (Runnable is super interface). Example (05:11) 5. What are the steps for thread? Method 1: • Extend your class from thread class. • Create your class object. • Override run method. • Call start method. Method 2: • Implement your class from runnable interface. • Override run method. • Create your class object. • Create thread class object and pass your class object as a parameter. • Call start method. E.g. main method and run method will run simultaneously. So, you will get output in different order every time. 6. We can use set and get priority method for (example as 36 min) 7. What is life cycle of thread? 8. What is isAlive method? 9. What is sleep method?