• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tips to visualize multithreaded applications

 
java boyinredglass
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello internets,

I find it really hard to understand multithreading because I can't find a way to visualize threads in my mind. Do you have simple ways of visualizing the various elements (locks, joins, synchronization, etc.) in a multi-threaded application?
 
Charles Latka
Greenhorn
Posts: 19
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it's quite easy... Check this for locks.
Synchronization... well it's everywhere e.g Airplane can't take off untill all passengers are on board and flight controll give permission. Passengers won't board until a gate is open, flight control won't give permission until the runway is clear- those all are threads needed to be synchronized.
The reader and writer problem... you can't read the file, when some is editing it. So you need to reserve (block) the file for you when you want to work with this file. When you block the file, and forget to free it after work, no one will be allowed do do anything with it... Try to google "semaphore"
Threads can work pararell, e.q you can build a house by yourself (one thread) but you can do it much faster with help of other workers (more threads)



 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found it helpful to keep swimlanes in my head. The way that many people think closely matches a collaboration diagram. THe conversation in their head goes like this:- "Foo calls Bar, Bar processes and creates thingamajigs. Bar sends the thingamajigs to doo-hickeys...." To me, this is thinking like you are drawing a collabration diagram. The problem is collabration diagram is not good at showing concurrent processes. It's good at showing which components are talking to which other components, but parallelism is lost. You might have an easier time if you think in swimlanes


Having said that I would like to add, the success of a highhly concurrent application lies in it's simplicity. If you are having problems following the code, you might want to rethink the design. Threads shouldn't interact with each other too much
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find a UML Activity Diagram or Interaction Overview Diagram useful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic