Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NotThreadSafe {
- private static final NotThreadSafe INSTANCE = new NotThreadSafe();
- private boolean isEven = false;
- private NotThreadSafe() {
- super();
- }
- public static NotThreadSafe getInstance() {
- return INSTANCE;
- }
- public String getMessage(final int num) {
- isEven = num % 2 == 0;
- System.out.println("isEven=" + isEven);
- if(isEven) {
- System.out.println("Returning foo");
- return "foo";
- } else {
- System.out.println("Returning bar");
- return "bar";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement