wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads/Concurrency is my weakness. Help very much appreciated. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads/Concurrency is my weakness. Help very much appreciated." Watch "Threads/Concurrency is my weakness. Help very much appreciated." New topic
Author

Threads/Concurrency is my weakness. Help very much appreciated.

Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 160
I have been searching for tips and techniques on answering Threads and Concurrency related questions here at JavaRanch. But I couldn't find any. Google search neither returns nice articles about tips on answering such kind of questions.

In the mocks if I encounter the word Thread I would often skip and then answer them last. It pretty scares me. I always get failing scores on Threads part on Mocks. I get low scores from other topics too but I guess this topic is where I'm least confident.

Do you know any articles about techniques on answering Threads and Synchronization?

For example, I found Corey's post about Garbage Collection very helpful. I thought pictures are for kids only so I refused to draw before and tried to picture what is happening only in my mind. When I read that post, I found out that what I was doing was very wrong. So I started drawing (and writing).

For Threads, usually I write the threads being started in columns and then write their corresponding outputs. After that I try to analyze the combination possibilities. However at some point my flow of thoughts just suddenly becomes unorganized.

I hope you can share your insights on how you answer Threads/Concurrency questions. Thank you!
[ September 02, 2008: Message edited by: Denise Saulon ]

SCJP/OCPJP 6 | SCWCD/OCPJWCD 5 | OCMJEA in progress...
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Well, I consider my concurrency part quite strong, Because I had developed one whole module of a big software alone which was completely based on threads..I found it quite difficult to explain threads using words, as it will stretch to quite long.
I prefer if you can make some small application using threads.
If will clear your concepts.


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 160
Thank you. I agree with you. It's quite difficult to trace/explain Threads by words or drawing. It usually gets messed up somewhere in the middle.

I agree too, that developing an application purely based on threads would help me. But do you have any suggestions for a kind of application I can develop that will widely use various concepts covered in the exam - synchronized, wait, notify, notifyAll, sleep, yield, etc...

Thanks again for your reply
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

I have one blur Idea, this is a part of project one of my friend was involved in.
Support you have four text files,
1.txt,2.txt,3.txt,4.txt --> you have to merge all these four files into one file.
but remember when one file is being written, no other file can be written.
Order of file doesn't matters.
but when you want to retrieve you just need to pass the file name.
you can make a hash-map : key --> file name and value --> location in merge.txt
Can create:
four thread corresponding to each text file, actually these number of threads should be flexible depending upon the number of files in the directory.
can create one listener thread, which will listen to directory as soon as file comes to directory it will shoot one thread which will write it content in the merge txt.

I hope you get an Idea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads/Concurrency is my weakness. Help very much appreciated.