• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Synchronization and Lock Confusion - Enthuware Sample

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to solve mocks in enthuware regarding concurrency. Here is the code given below


The options are
True
False

The answer is b. My first question is that, as these are two different instances over which a non-synchronized
method is invoked which in turn invokes the two synchronized methods simultaneously. My first question is that,
as they are invoked on two different instances, so calling of the synchronized methods should not block each other.
Is that correct? Will these two thread executing parallel or one will be in the runnable pool. Please sorry for the stupid
questions, but really confused in threads.

Though seems like my first assumption is incorrect. Please help.

Thanks,
Arhaan
 
Sheriff
Posts: 9692
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes since there are two instances here, the two threads can execute setX and setY method at the same time. Now you've only written the options and not the actual question so I can't say whether your answer is right or not...
 
Arhaan Singhania
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ankit. I have cleared the confusion i was facing. Thanks a ton.
Arhaan
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic