• Post Reply Bookmark Topic Watch Topic
  • New Topic

AtomicLong.intValue() Vs AtomicInteger.intValue()  RSS feed

 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both AtomicInteger and AtomicLong has intValue() in the java.util.concurrent.atomic package. What is the difference ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kri shan wrote: Both AtomicInteger and AtomicLong has intValue() in the java.util.concurrent.atomic package. What is the difference ?


Both the AtomicInteger and AtomicLong classes subclass the java.lang.Number class. The intValue() method is a method of that super class... and here is the details from the JavaDoc.

Returns the value of the specified number as an int. This may involve rounding or truncation.


So, AtomicInteger returns the integer value as an integer. And AtomicLong returns the long value which may be truncated to an integer (as an integer).

Henry
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!