Guest User

Untitled

a guest
Jun 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public class Multiply { // Example of multiply with AtomicInteger
  2.  
  3. public static void main(String[] args) {
  4.  
  5. int x,y;
  6.  
  7. x = 2;
  8. y = 5;
  9.  
  10. AtomicInteger control = new AtomicInteger( (!(x<y)) ? x : y );
  11. AtomicInteger condition = new AtomicInteger( (x<y) ? x : y );
  12.  
  13. System.out.println( control.get() );
  14. while ( condition.decrementAndGet() > 0 ) {
  15. System.out.println( control.addAndGet( (!(x<y)) ? x : y) );
  16. }
  17. }
  18. }
Add Comment
Please, Sign In to add comment