Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread synchronization query

 
Abhishek Purwar
Ranch Hand
Posts: 63
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have query for thread synchronization.

Suppose there are three threads and there is one method which takes number as input and prints number.
If threads passes same number, number should print one time and if different numbers provided as input then all different number should print.

For e.g.
If thread1 and thread2 passes 1 as input to method and thread 3 passes 2 as input then 1 should print once and 2 should print once.
If thread 1 passes 1, thread 2 passes 2 and thread 3 passes 3 then all number should get printed as all are different.

Please suggest me how I shall achieve this.

Regards,
Abhishek
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you approach it and why? Think about it for a bit and then try coming up with an SSCCE you can post here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic