Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2008, 09:32 AM
Registered User
 
Join Date: Jan 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default program that calls its method automatically

hi,
i have to make a simple program which automatically calls a method after each 25 microseconds.Let say i have a program which looks like :

public static void main(String[] args)
{
      void method1(void)
      {
       //method defination
      }
System.out.println("my name is wallam");
}
The method "method1" is called automatically after each 25 microseconds and rest of the program execute as normal.So please give me the code for this program.

 
Old January 23rd, 2008, 11:34 PM
jomet
Guest
 
Posts: n/a
Default

Hi,

Use two java.lang.thread
on the first thread
{
method1()
// Thread.sleep(25); can be used for waiting 25ms
// call the method recursively
// a condition should be given to stop the thread[dont get into infinite loop]
}

second thread
{
//rest of the program
}

Cheers,


jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
 
Old January 28th, 2008, 08:32 AM
Registered User
 
Join Date: Jan 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx buudy
but u used the method "Thread.sleep(25)" which delays for 25 miliseconds not for microseconds
Quote:
quote:Originally posted by jomet
 Hi,

Use two java.lang.thread
on the first thread
{
method1()
// Thread.sleep(25); can be used for waiting 25ms
// call the method recursively
// a condition should be given to stop the thread[dont get into infinite loop]
}

second thread
{
//rest of the program
}

Cheers,


jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
 
Old January 29th, 2008, 06:50 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#sleep(long,%20int)

Code:
public static void sleep(long millis,
                         int nanos)
                  throws InterruptedException
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
program that call its method automatically mfahadwallam BOOK: Beginning Java 2 0 January 28th, 2008 09:26 AM
Proxy class method calls: No error, No data! corin .NET Web Services 0 September 11th, 2006 08:33 PM
Method calls within same class w/Interface gmontanaro C# 0 April 6th, 2006 05:44 PM
object parameters to remote method calls DotNetJunk General .NET 1 April 29th, 2005 04:02 AM
Third party program library method calls invocatio yeeck VB Components 0 June 20th, 2003 01:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.