This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronized  RSS feed

 
Allan Tan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following can be synchronized ?
methods?
member variables?
local variables?
code blocks?
static/non-static class?
 
Paul Caudle
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Allan,
Methods and code blocks are the only items in your list that may be synchronized.
A method may be synchronized using it in the header as in:

and a block of code may be syncronized like the following:

I hope that helps,
Paul
[This message has been edited by Paul Caudle (edited November 06, 2000).]
[This message has been edited by Paul Caudle (edited November 06, 2000).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!