DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Posts
    5

    how to run the program continously...

    i want to run my java program continously... i heard that by implement the thread we can run program continously... can any body give me sample code on thread which runs continously....

    thanks alot
    kareem

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    nothing to do with threads.. just put an infintie loop in your main:

    Code:
    ..
    
      public static void main(String[] argv){
        for(;;){
          //do stuff
        }
      }
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  3. #3
    Join Date
    May 2004
    Posts
    29
    or u can always use the while or do-while

    while (condition)
    {
    do something
    }

    prg will keep on going until the condition changes


    do
    {
    do something
    }
    while (condition)

    prg will do it once then will continue on doing it after it checks the condition where it'll stop once that condition ceases to exist

  4. #4
    Join Date
    Feb 2004
    Posts
    808
    while and do loop, rewritten to use a for loop:

    while(condition)
    for(;condition;)

    do{}while(condition)
    for(boolean doo=true;doo;doo=condition)
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  5. #5
    Join Date
    Oct 2002
    Posts
    12
    If you defanetly need threads, though... it's
    Code:
    Thread runner=new Thread(new Runnable(){
      public void run(){
        while(true){ //infinite loop
          //do stuff
        }
      }
    }
    runner.start();
    however, you really don't need a thread for your resquest unless you want concurrently running processes

  6. #6
    Join Date
    Feb 2004
    Posts
    808
    Originally posted by sukuri
    If you defanetly need threads...
    ...
    however, you really don't need a thread...
    So what's it to be, tiger? does he need a thread or not?

    ps; it's "definitely", from "define"
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links