?
Solved

decreasing value of cell dynamycally

Posted on 2004-08-10
7
Medium Priority
?
215 Views
Last Modified: 2011-04-14
i have a table with fields,and i want that one of
these fields show a value(integer) that must be decreased dynamically each second.
how can i do this?
thanks,
0
Comment
Question by:kimo100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764426
use timers for that
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764442
int delay = 5000;   // delay for 5 sec.
    int period = 1000;  // repeat every sec.
    Timer timer = new Timer();
   
    timer.scheduleAtFixedRate(new TimerTask() {
            public void run() {
//              your table cells code here
            }
        }, delay, period);
0
 

Author Comment

by:kimo100
ID: 11786177
i use JDK1.2,and the classes Timer and TimerTask don't exist.
could you tell me if there is some thing equivalent in this release of JDK.
thanks
0
 
LVL 35

Accepted Solution

by:
girionis earned 1000 total points
ID: 11850738
new Thread()
{
    public void run()
    {
        while (true)  // run forever
        {
            // your table cells code here.
            // sleep for one second
            Thread.sleep(1000);
        }
    }
}
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 11865663
Hi kimo100,

girionis's suggestion is the solution unless you want more time precision (launch the task even if the last was not terminated) :

class MyTimerTask extends Thread
{
    public void doJob()
    {
          try{
          for(;;)
          {
               synchronized(this)
               {
                    wait();

                    // ...

               }
          }
          }catch(Exception ex){}
    }

    public void run()
    {
          Thread jobth=null;
          try{
          jobth=new Thread(){
             public void run(){doJob();}
           };
          jobth.start();
          for(;;)
          {
               synchronized(this)
               {
                    notify();
                    Thread.sleep(1000);
               }
          }
          }catch(Exception ex){}
          jobth.interrupt();
    }
}

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question