Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Waiting until files are being created

Thread view: 
Wesley Mesquita - 04 Mar 2008 01:54 GMT
Hi all,
I am having a problem that in a software that I am developing there is
some ammount of code that invokes console commands (using Runtime
exec). These include directory creation, file compilation and so on.
Following the software flow, most of time I need  these created files
immediatally after run Runtime exec and because the system delay they
aren´t ready, so I have to wait until the files have been created. My
poor solution has been an empty loop with a new File object and stay
asking if the files exists (or even worse I thought to put a
Thread.sleep(time)).

My question is: Is there any better solution to deal with this?

Thanks in advance.
Knute Johnson - 04 Mar 2008 03:21 GMT
> Hi all,
> I am having a problem that in a software that I am developing there is
[quoted text clipped - 10 lines]
>
> Thanks in advance.

Why don't you just create the files and directories in Java?

Signature

Knute Johnson
email s/nospam/knute/

     ------->>>>>>http://www.NewsDem

Wesley Mesquita - 04 Mar 2008 10:51 GMT
On Mar 4, 12:21 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > Hi all,
> > I am having a problem that in a software that I am developing there is
[quoted text clipped - 21 lines]
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
>       ------->>>>>>http://www.NewsDem

Directories I am creating using File (I made a mistake in first post),
but I still have to compile some java sources. I´ll see the tips that
Roedy gave (specially Batik), and soon I´ll post the results.

Thanks
Roedy Green - 04 Mar 2008 07:13 GMT
On Mon, 3 Mar 2008 17:54:13 -0800 (PST), Wesley Mesquita
<wesleymesquita@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>My question is: Is there any better solution to deal with this?

Yes. Don't use command scripts. Do it directly from Java. See
http://mindprod.com/jgloss/file.html and
http://mindprod.com/products1.html#BATIK for how.

If you must use scripts, your code becomes platform dependent.  But
you can wait. See http://mindprod.com/jgloss/exec.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Thomas Kellerer - 04 Mar 2008 10:56 GMT
Wesley Mesquita, 04.03.2008 02:54:
> My poor solution has been an empty loop with a new File object and stay
> asking if the files exists (or even worse I thought to put a
> Thread.sleep(time)).

Thread.sleep() is a lot better than having an empty loop as it will release CPU cycles and will not waste CPU time in a loop which doesn't do anything.

So if you need to call exec() and have to wait for it, by all means use Thread.sleep() while polling for the existence of the file.

Thomas
Wesley Mesquita - 04 Mar 2008 11:16 GMT
> Wesley Mesquita, 04.03.2008 02:54:
>
[quoted text clipped - 7 lines]
>
> Thomas

I thought it is worse since I don´t how much time put it to sleep. For
instance, if it needed 500ms and I put 2000ms I waste 1500ms.
Thomas Kellerer - 04 Mar 2008 11:34 GMT
Wesley Mesquita, 04.03.2008 12:16:
>> Wesley Mesquita, 04.03.2008 02:54:
>>
[quoted text clipped - 9 lines]
> I thought it is worse since I don´t how much time put it to sleep. For
> instance, if it needed 500ms and I put 2000ms I waste 1500ms.

It's still more efficient to use 500ms (or even 100ms) compared to not waiting at all.

Thomas


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.