Monday 12 November 2012

Producer-Consumer sample - Listing files

Listing files is reeally slow operation.

That's why I decided that it will be a good use case to have some fun with java's concurrency.

Producer-Consumer pattern seemed to fit my needs.
  1. Producer is listing all files from given directory. 
  2. Consumer is filtering proper files and propagates this data to GUI in real-time. 
  3. Both are connected by BlockingQueue
BlockingQueue<List<File>> myQueue = new LinkedBlockingQueue<List<File>>();

Please find my sources @ https://bitbucket.org/pawelmichalski/repo/src.

... Actually I should write something about my code to justify some of my implementating decisions, but it's being late right now in Poland :) so consider this entry as asking for code review in some free time.


cheers.

2 comments: