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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

synchronized threads

Status
Not open for further replies.

rolfjf

Programmer
Jun 13, 2000
8
BR
Hi, my name is Rolf and I'm from Brazil.<br><b>How can I make a program that uses synchronized parallel processing?<br>Someone has source code with examples of using the threads to do this?<br>It must be synchronized. Like reading/writing in a buffer or other things like processing<br>&nbsp;fuel bombs or a telephone operator. It can be just a simple example. </b><br>Thank you<br>Rolf
 
I have a question along this line, I have written a file copy program and I wish to use threads to speed up the copy process. Lets say I have a directory with a 100 files (known to the program before copying). What I would like to do is have three threads, one to copy 34 files and the other two to copy 33 files each. Assuming the transfer speeds of the files would be the same, I would have three files transfering at the same time. I can do it with one thread i.e. all java programs have at least one thread (as far as I know?).<br><br>Would this be feasible to do, as I would really like to learn something about threads? Thanks in advance. <p> fenris<br><a href=mailto:fenris@hotmail.com>fenris@hotmail.com</a><br><a href= > </a><br> I am interested in Mining Software, as well as Genetic Algorithms.
 
Really it's a good question! <br>One simply solution is that, you write a Threaded Class ie., a class which extends Thread or implements Runnable. Instantiate three different objects for the same class and the thru the constructor pass three different parameters namely the files and the destination directory. And, call the start() function, which would obviously start three threads simultaneously.
 
Rolf, I have the book &quot;Java How to Program&quot; by Deitel and Deitel. They have a web site with all the examples in the book. Chapter 15 is on mutiple threading and they have examples with synchronization. Go to <A HREF=" TARGET="_new"> and on the left side is a download link. The link has examples from all their books, so go to the book &quot;Java How to Program&quot; and download the examples and then look at the directory called ch15.<br><br>Jerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top