You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BasicProgram1.java 378B

123456789101112131415161718192021
  1. // Subject to LTW
  2. public class BasicProgram1 {
  3. public static void main(String[] args) {
  4. new BasicProgram1().nonstaticM();
  5. staticM();
  6. }
  7. public static void staticM() {
  8. synchronized (String.class) {
  9. System.err.println("static method running");
  10. }
  11. }
  12. public void nonstaticM() {
  13. synchronized (this) {
  14. System.err.println("nonstatic method running");
  15. }
  16. }
  17. }