Skip to main content

Posts

Showing posts with the label java Runnable

Threading

Threading:- Thread is a public class in java which internally implements Runnable interface, Runnable interface having only one method that is run method. Purpose of thread class and Runnable interface is to achieve multitasking programming, in a normal programming we know the flow of program execution because normal methods execute sequentially and this sequence is possible through stack all the processes run in a common stack. Thread is a lightweight process which is run in separate stack space, so all the threads run in separate stack space simultaneously that’s why threads run independently. If in a program more than one thread executing this process called multi threading. Order of execution of threads are depends on thread scheduler. In short multi threading is many thread objects want to execute same piece of code for example many people online book tickets here peoples are thread object and tickets are that piece of code which is written in run() method. Threading is...