• 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

Single threaded to multi-threaded design

 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have got a FTP processes that moves data from Linux to NT.
It's now designed as a single threaded application.
In near future we are likely to get more number of files for FTP'ing.
Is there any design pattern or could any one tell me a good design,
to convert this application as a multi-threaded one. so that the files can be ftp'd as soon as it comes to Linux.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you hope to gain from multi-threading? Isn't the transfer likely to be bounded by network bandwith?
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I thought was, by going though a multithreaded design, we can ftp multiple files at the same time. Each thread would take care of FTP'ing group of files and move it to a backup folder.

Is that not good ? Am I going wrong ?
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Srinivasa - You are not way off base with this idea. Multi-threading will help offset network IO wait times (unless your net is already saturated).

I do this frequently with network (not FTP) transfers.

You will gain throughput: files/second or bytes/second or however you are measuring it.

You must experimentally determine the "best" value for the maximum number of threads. Too many can hurt rather than help.

Guy
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java 5 Executor Interface and related concurrent APIs should help you out in designing the same. The intention of Executor Class is as follows...

This interface provides a way of decoupling task submission from the mechanics of how each task will be run, including details of thread use, scheduling, etc



It also provides convenient implementations for creating various types of thread pools. see the links below.

http://java.sun.com/j2se/1.5.0/docs/guide/concurrency/overview.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic