• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about pausing of execution

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,

is there any way to pause execution of a part of java program for a particular time without using Thread.sleep() method


thanks,


bye
kalyan
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Well, there is Thread.suspend, but it's deprecated. Anyway, why would
you like to do that? (I mean, your question is quite vague. Tell us more
and we might be able to help.)

Petr
 
kalyan at tcs
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

in my program , iam having 2 methods which display screens on screen ,
and iam calling them sequentially , hence iam not able to see the output of first method .so i want to pause execution of my program for some time at end of first method and before the second , so that i can view outputs of both

i was restricted not to use Thread concept , pls help me , is there is any other way to over come this


bye
kalyan
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could put in code that waits for some user input before proceeding, a bit like C's getch()

For example,



displays 'Hello', and then waits for the user to press Enter, before displaying 'World'.

Would this solve your problem?
 
kalyan at tcs
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

i had nothing to input from user


bye

kalyan
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is pretty ugly, and pretty much locks up the app, but you could do:
 
kalyan at tcs
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Jason Fox ,

thanks for ur help


bye

kalyan
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i was restricted not to use Thread concept



This is a rather vague restriction. Does this mean you can't use threads? If so, you can't start a JVM (which uses threads), and therefore, the problem is outside the scope of Java.
Does it mean you can't use the java.lang.Thread API? If so, perhaps your teacher is hinting at the use of Object wait/notify/notifyAll.

It is important to note that you can NEVER have a thread pause for a specific period of time - you can however, have a thread pause for at least a specific period of time. When that thread comes out of 'sleep' state it is put into 'ready for execution' state - not 'running' state. It is up to the indeterminate thread scheduler to decide when the thread is shifted to 'running' state.
 
reply
    Bookmark Topic Watch Topic
  • New Topic