![]() |
Introduction to threads in Java
A thread, by definition is a light weight process. They are used to increase functionality and performance by performing multiple tasks at the same time, i.e. concurrently. There are two methods for implementing threads in Java,
Now, let's jump onto the coding part on how to actually create threads. The first method is to extend or inherit the 'Thread' class. The 'Thread' class is defined in the package java.lang, which needs to be imported. Take a look at the code below to get a better idea, Code: Java
Code: Java
|
Re: Introduction to threads in Java
Below, it says <next thread> and <previous thread> !!
Is it in any waiz related to the above topic ???????? ...... Hey guys don't get furious on readin this !!! I m just tryin to be funny !!!! Any waiz, good work u all are doin !!! KEEP GOIN GUYS !!! |
Re: Introduction to threads in Java
:p By the wat welcome to G4EF forum.
|
Re: Introduction to threads in Java
Hi Pradeep ,
Can you please illustrate this with greater detail .. taking examples on each of impl., that would help understand the concepts in a practical way ? thanks .. HS |
Re: Introduction to threads in Java
It is better in the long term to use the implements runnable interface as this will make your code more extendible in the future as you can also have threads that subclass other classes other than just Thread. What is not mentioned is that the thread has a shared state from the calling class which brings in the Synchronized keyword when changing the state.
|
Re: Introduction to threads in Java
hey pradeep don't you think that java.lang is provided by default....it doesn't need to be imported on any program....
|
Re: Introduction to threads in Java
In java we declare thread in two ways
There are two methods for implementing threads in Java,
|
Re: Introduction to threads in Java
there are java recomonded thread ... searching for good java script editing software.
|
| All times are GMT +5.5. The time now is 02:00. |