Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public class NotThreadSafe {
  2.  
  3. private static final NotThreadSafe INSTANCE = new NotThreadSafe();
  4.  
  5. private boolean isEven = false;
  6.  
  7. private NotThreadSafe() {
  8. super();
  9. }
  10.  
  11. public static NotThreadSafe getInstance() {
  12. return INSTANCE;
  13. }
  14.  
  15. public String getMessage(final int num) {
  16. isEven = num % 2 == 0;
  17. System.out.println("isEven=" + isEven);
  18. if(isEven) {
  19. System.out.println("Returning foo");
  20. return "foo";
  21. } else {
  22. System.out.println("Returning bar");
  23. return "bar";
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement