Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with a thread

Status
Not open for further replies.

bos

Technical User
Oct 1, 2002
50
US
I'm working on a program which has a thread. The thread does the following:

1. Creates a file.
2. Runs a chmod 700 on the file so that I can run it.(AIX)
3. Runs the actual file.
4. Filters a file which step 3 creates while running.
5. Writes the filtered results to a final file.

The problem I'm having is that it takes time to write to files and run certain commands. There is not enough time in between the steps and I get errors because the step before is not yet complete. Is there a way I can put pauses in the thread so that it will run right? Please let me know. If necessary I can post the syntax of the thread.

Thanks in advance.
 
You might try adding <b>synchronized</b> in front of the methods. This causes the VM to finish that method before starting a new one. --Derek

<i>&quot;Fear not the storm for this is where we grow strong.&quot;</i>
 
Hmmm...HTML isn't supported.
Ok let me re-admit the previous.

You might try adding synchronized in front of the methods. This causes the VM to finish that method before starting a new one.

Much better.

--Derek

&quot;Fear not the storm for this is where we grow strong.&quot;
 
No synchronized guarantees that one thread will be allowed execute the given code block at any one time. It does nothing to synchronize timing issues with other processes running in the JVM.
 
I guess Thread.sleep(<interval>) will pause the thread but I'm not sure if that will do what you want. --Derek

&quot;Fear not the storm for this is where we grow strong.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top