Posts

Showing posts from February, 2015

Threads in java

Image
Threads in java What are threads :For understanding threads we must firstly know,what is a process? A process is a background activity running besides doing some works at a piece of time.A machine operating system runs a lot of processes to do a task such as opening a program,booting up,loading resources etc.So next question is what is a thread? A thread is a light weight process,i.e. threads do small piece of work in a particular duration.It has a start start,running state,waiting and terminated state.There is a default thread running in a java program,if you have noticed:its the main thread. Why do we need threads? Suppose in a situation where we are creating a project where a program does two or more piece of work at the same time,for example processing a mouse click on a button and opening the other frame of project at the same time.HOW CAN WE DO THAT??The power comes with multithreading. How threads works? The threads are started using start() method,that gives call