Home Answers Viewqa Java-Beginners Extending thread

 
 


joginder singh
Extending thread
1 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

View Answers

October 31, 2008 at 3:59 PM


Hi friend,


Thread :

A thread is a lightweight process which exist within a program and executed to perform a special task. Several threads of execution may be associated with a single process. Thus a process that has only one thread is referred to as a single-threaded process, while a process with multiple threads is referred to as a multi-threaded process.

For example :

class SimpleThread extends Thread {
public SimpleThread(String str) {
super(str);
}
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(i + " " + getName());
try {
sleep((int)(Math.random() * 1000));
} catch (InterruptedException e) {}
}
System.out.println("DONE! " + getName());
}
}

For more information,Tutorials and Examples visit to :

http://www.roseindia.net/java/thread/index.shtml

Thanks









Related Pages:
Extending thread - Java Beginners
Extending thread  what is a thread & give me the programm of exeucte the thread   Hi friend, Thread : A thread is a lightweight... that has only one thread is referred to as a single-threaded process, while
Create Thread by Extending Thread
Create Thread by Extending Thread This section explain how to create thread by extending Thread class in java. Extending Thread : You can create thread by extending Thread class and then by creating instance of that class you can
Java Thread class
It is created by extending the Thread class or implementing Runnable interface Java Thread Class Example public class thread1 extends Thread { @Override... Java Thread Class is a piece of the program execution Java has
Thread Creation
. Extending the java.lang.Thread Class For creating a thread a class have to extend... to extending the Thread Class: If you extend the Thread Class, that means... Thread Creation      
Get Current Thread
way to create Thread- 1)Implements Runnable interface. 2)By extending the ... Get Current Thread       A Thread is the independent path of execution in a program
objective c extending a class with a class
objective c extending a class with a class  I need an example for extending a class with a class in objective c. thanks
objective c extending a class with a class
objective c extending a class with a class  I need an example for extending a class with a class in objective c. thanks
thread
thread  can parent thread be dead if child thread is not dead
Thread
Thread  Thread Life Cycle
Thread
Thread  what is the use of thread
Thread
Thread  Explain two ways of creating thread in java. Explain at three methods of thread class.   Java Create Thread There are two main ways of creating a thread. The first is to extend the Thread class and the second
Thread
Thread  What is multi-threading? Explain different states of a thread... processor system. States of Thread: New state ? After the creations of Thread instance the thread is in this state but before the start() method invocation
Thread
to the thread constructor eventhough we had created only one thread and if you say we have added to point to the current thread then why we have not added this in the following line "s=s1" Pls reply...... class MyThread extends Thread { Thread
Java Thread : run() method
() : By extending the Thread class, run() method is overridden and put all...Java Thread : run() method In this section we are going to describe run() method with example in java thread. Thread run() : All the execution code
Thread
Thread  what happen when we call the Wait(),Notify() and NotifyAll() methods in the Thread
Thread
Thread  class Extender extends Thread { Extender(Runnable run...(); } public void run(){ System.out.println("Extender Thread is Started :"); //new Thread(new Implementer()).start(); } } class Implementer
Thread
Thread  will this code work..? class A extends Thread { public...=" + i); } public static void main(string args[]) { A a = new A(); Thread t = new thread(a); t.start(); } } Is it possible to run above program with out
Thread
Thread  Write a Java program to create three theads. Each thread should produce the sum of 1 to 10, 11 to 20 and 21to 30 respectively. Main thread....   Java Thread Example class ThreadExample{ static int
Thread
Thread   there are two threads running at a time.. when am updating a values in database. both thread halt and stop for moment till it get updated into database... so i dnt want thread to get halts for tht moment of period. whats
Needed modifications to ApplicationContext if extending this application
Needed modifications to ApplicationContext if extending this application   I followed the Developing Struts Hibernate and Spring Based Login/Registration Application tutorial and that is very good. Now I need to modify
Needed modifications to ApplicationContext if extending this application
Needed modifications to ApplicationContext if extending this application   I followed the Developing Struts Hibernate and Spring Based Login/Registration Application tutorial and that is very good. Now I need to modify
Runnable interface in java
In this section we will learn about Runnable interface in java. In java thread are created by two ways, one by extending Thread class and another one by implementing Runnable interface
Diff between Runnable Interface and Thread class while using threads
problems. 2)Extending the thread will give you simple code structure in comparison...Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  
Diff between Runnable Interface and Thread class while using threads
problems. 2)Extending the thread will give you simple code structure in comparison...Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  
Difference between extends thread class vs implements runnable interface - Java Interview Questions
Difference between extends thread class vs implements runnable interface  Hi Friends, can you give difference between extending thread class... and also avoid the single inheritance problems. 2)Extending the thread
Thread in java
Thread in java  which method will defined in thread class
Thread restart
Thread restart  hello,, can dead thread restart?   hii, A dead Thread can't restart not even by calling start() again on that object
Daemon thread
Daemon thread  what is need of daemon thread
java Thread
java Thread  what is purpose of Thread
Daemon thread
Daemon thread  what is need of daemon thread
Java thread
Java thread  How can a dead thread be restarted?  A dead thread cannot be restarted
Creating Flex ActionScript Custom Component extending Button
; } Creating Flex ActionScript Custom Component extending Button  ...,  a custom button component is created by extending Button class.  
Java thread
Java thread  What's the difference between a thread's start() and run() methods
Java thread
Java thread  What is the difference between process and thread
Thread method
Thread method  What is the purpose of the wait(), notify(), and notifyAll() methods
Java thread
Java thread  What invokes a thread's run() method
Java thread
Java thread  What are the ways in which you can instantiate a thread
Java thread
Java thread  What are the high-level thread states
Demon thread
Demon thread  What is demon thread? why we need Demon thread?  ... there are daemon thread by killing them abruptly.Any thread can be a daemon thread.../thread/daemon-threads.shtml
Thread scheduling
Thread scheduling  What is the algorithm used in Thread scheduling?  Java uses fixed-priority scheduling algorithms to decide which thread... on the basis of their priority relative to other Runnable threads. The thread
daemon thread
daemon thread  hello, What is a daemon thread?   hello, These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly
Java thread
Java thread  Why do threads block on I/O?   When a thread... and in that time some other thread which is not waiting for that IO gets a chance to execute.If any input is not available to the thread which got suspended for IO
Thread in Nutshell
Thread in Nutshell  Hi, I m confused about what is called a thread actually in a program. There are many answer to this question on the web...; Please go through the following link: Thread Tutorials
Thread concept
Thread concept  Everytime when i run a multithread program it gives... in advance friends. Happy new year!!!!! class Newthread3 implements Runnable{ Thread t; String name; Newthread3(String threadname){ name=threadname; t=new Thread
thread dump
thread dump  Hi, I wanted to understand the Locked/waiting state below in the java thread dump. Is it normal to have waiting on locked object monitor value to be same, in the snippet below both are<0x701dd1e0> i see a lot
Main Thread and Child Thread
and Child Threads used in Programming. Main thread is automatically created when program runs. Child Thread gets created by the main thread . Java Main Thread Example public class mainchild implements Runnable { Thread t1
Exception in thread
Exception in thread   Hi, I have created a java file for sending a file to my mail. I am using mail.jar file. I am able to create .class file...:\mail.jar SendMailTLSDFC Exception in thread "main" java.lang.NoClassDefFoundError

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.