Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  




Share on Google+Share on Google+

Antony Devassy
2 Answer(s)      8 years ago
Posted in : Java Beginners
View Answers

September 15, 2008 at 3:23 PM

hi antony
try this may be you got some idea
package com.pack1;

class TestTwo extends Thread
private static int sums;

public static int getSums() {
// System.out.println("buddy " + TestTwo.sums);
return TestTwo.sums;
public static void setSums(int val) {
int result = val;
TestTwo.sums = TestTwo.sums + result;
public static void main(String ar[])throws Exception
// System.out.println("hello " + getSums());

public static void fgh(final int i,final int p)
int val = 0;
( new Thread() {

public void run() {
int sum = 0;
int t = p;
int o = i;
for(;o < t; o++) {
sum = sum + o;





September 15, 2008 at 3:31 PM

Hi friend,

class RunnableThread implements Runnable {

Thread rund;
public RunnableThread() {
public RunnableThread(String threadName) {
rund = new Thread(this, threadName);
public void run() {

public class ThreadImp {

public static void main(String ar[]) {

Thread th = new Thread(new RunnableThread());
System.out.println("Numbers are printing line by line : ");
for(int i = 0;i <= 9;i++)
catch(InterruptedException e){


Visit for more information.



Related Tutorials/Questions & Answers:
java Thread
java Thread  what is purpose of Thread
Java thread
Java thread  How can a dead thread be restarted?  A dead thread cannot be restarted
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
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
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 java
Thread in java  which method will defined in thread class
Java Thread and Runnable
Java Thread and Runnable  What's the difference between Thread and Runnable types
How to Differenciate Main Thread and Child Thread in Java
Main Thread and Java Child Thread. Please Suggest any example or online link... in Java Programming Language. These are Java Main Thread and the Child Thread. The Below reference will provides you clear idea of java thread concept. http
Java thread
Java thread  What is the use of serializable
Java thread
Java thread  What is the difference between wait() and sleep method
Java thread
Java thread  What method must be implemented by all threads
Java thread
Java thread  Can we have run() method directly without start() method in threads
Java thread state
Java thread state  what is Static binding
Thread - Java Beginners
the concept of thread, thread creation and use of threads in JAVA application?  Thread creation and use of threads in JAVA Java Resource
how to destroy java thread
how to destroy java thread  how to destroy java thread?   This will help .. Shutting Down the Java Thread
Java thread lock
Java thread lock  What happens when a thread cannot acquire a lock on an object
Java thread state
Java thread state  What is the difference between yielding and sleeping
Java thread state
Java thread state  Difference between sleep and suspend
Java Thread
Java Thread In this tutorial we will discuss about Java Thread. Java Thread : A thread is light weight java program.JVM permits you to have multiple threads for concurrent execution. Each thread has priority. You can also set
thread - Java Beginners
thread  can i asko for programs in thread method that will allow user to input two separate names  Hi friend, For more information on Thread visit to : Thanks
Java Thread
Java Thread Tutorials In this tutorial we will learn java Threads in detail. The Java Thread class helps the programmer to develop the threaded application in Java. Thread is simple path of execution of a program. The Java Virtual Machine
Daemon thread - Java Beginners
information, visit the following link: thread  Hi, What is a daemon thread? Please provide me... thread which run in background. like garbadge collection thread. Thanks 
Java Thread - Java Beginners
and simple examples of "Multithreading". 1. 2. Thread  hii i feel confusion in tread. i want to know about 1
Java Sleep Thread
Java Thread sleep() is a static method. It sleeps the thread for the given time in milliseconds. It is used to delay the thread. It is used in Applet or GUI programming for animation Java Sleep Thread Example public class
JAVA THREAD - Java Beginners
JAVA THREAD  hii i wrote a pgm to print the numbers from 0 to 9 in 2...); } public void fgh(int i,int p) { int sum; new Thread(public void run... Thread { private static int sums; public static int getSums
Extending thread - Java Beginners
visit to : Thanks...Extending thread  what is a thread & give me the programm of exeucte the thread   Hi friend, Thread : A thread is a lightweight
Java :Thread getPriority Example
Java :Thread getPriority Example In this tutorial you will learn how to get thread priority in java thread. Thread getPriority() : Thread scheduler uses thread priority concept to assign priority to the thread. A higher priority 
java thread program
java thread program  write a java program to find out the current running thread in a java program   public class RunningThreads{ public...() + ":" + group.getClass()+"]"); int count = group.activeCount(); Thread[] threads