Solved

decreasing value of cell dynamycally

Posted on 2004-08-10
7
206 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 250 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
spring jars download 1 67
How to convert from xls to xlsx using java 7 144
eclipse console opening separately 2 46
Cisco ASA: Java web start no go, asdm launcher no go 3 84
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

737 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