THREAD - Java Codes

Thread Inner Classes

Description This code shows the implementation of threads with inner classes. Source Code class InnerThread1 { private int countDown = 5; private Inner inner; private class Inner extends Thr ...

0 Comments. 8040 views since Sep 10, 2008

Swing and Thread for Length Operation

Description This code shows the lengthy process for searching a particular bank account's remaining balance. Source Code package yfrindia; import java.awt.BorderLayout; import java.awt.FlowLayout; ...

0 Comments. 2583 views since Sep 11, 2008

Counter with Swing & Thread

Description This code shows a circle which on pressing of start button starts filling the circle with red colour and on pressing stop, stops the activity. Source Code import java.awt.BorderLayout; impor ...

0 Comments. 2435 views since Sep 10, 2008

Stop Thread

Description This code defines a safe way of stopping a thread. Source Code package yfrindia; import java.util.Timer; import java.util.TimerTask; class CanStop extends Thread { private volatile ...

0 Comments. 1231 views since Sep 10, 2008

Thread Reminder

Description This code shows simply a reminder procedure to schedule a task. Source Code package yfrindia; import java.util.Timer; import java.util.TimerTask; public class Reminder { Timer t ...

0 Comments. 1214 views since Sep 10, 2008

Thread Sleep

Description This code describes you the functioning sleep() method in java. Source Code public class SleepingThread extends Thread { private int countDown = 5; private static int threadCount = ...

0 Comments. 1195 views since Sep 10, 2008

Swing with Thread

Description This code shows the working of swing and Thread together. Source Code import java.awt.BorderLayout; import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent ...

0 Comments. 1172 views since Sep 10, 2008

Race Condition

Description This code shows the race conditions using the swing components. Source Code import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.WindowAdapter; import java.awt.ev ...

0 Comments. 1162 views since Sep 10, 2008

Eliminating Race Condition

Description This code shows how to eliminate race conditions if any in the component. Source Code import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.WindowAdapter; import j ...

0 Comments. 1143 views since Sep 10, 2008

Thread Priority

Description This code shows how can we assign priority to the threads. Source Code public class SimplePriorities extends Thread { private int countDown = 5; private volatile double d = 0; publi ...

0 Comments. 1116 views since Sep 10, 2008

Thread Synchronization

Description If a method declared as the synchronized at a time only one thread is allowed to execute that synchronized method on any given object or class. Every Object in java has a lock. At the time of synchronization only the lock concept wi ...

0 Comments. 1093 views since Mar 24, 2011

Runnable Interface

Description This code shows how to create a thread with runnable interface. Source Code public class RunnableThread implements Runnable { private int countDown = 5; @Override public String toS ...

0 Comments. 1091 views since Sep 10, 2008

Threads Race

Description This code shows the race among the threads for execution. Source Code public class Race { private final static int NUMRUNNERS = 2; public static void main(String[] args) { Self ...

0 Comments. 1090 views since Sep 10, 2008

Yeild Thread

Description This code is for Suggesting when to switch threads with yield() Source Code public class YieldingThread extends Thread { private int countDown = 5; private static int threadCount = ...

0 Comments. 1086 views since Sep 10, 2008

Thread Printing

Description This is a Code which shows how to Print a simple Thread. Source Code import java.applet.Applet; import java.awt.Graphics; import java.awt.TextArea; public class PrintThread extends Apple ...

0 Comments. 979 views since Aug 28, 2008

Runnable Interface in Swing

Description This code shows the use of Runnable Interface with Swing Components. Source Code import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Graphics; imp ...

0 Comments. 957 views since Sep 10, 2008