public class Test implements Runnable { Integer id; public static void main(String[] args) { new Thread(new Test()).start(); new Thread(new Test()).start(); } public void run() { press(id); } synchronized void press(Integer id) { System.out.print(id.intValue()); System.out.print((++id).intValue()); } }
Integer id;
public static void main(String[] args) {
new Thread(new Test()).start();
}
public void run() {
press(id);
synchronized void press(Integer id) {
System.out.print(id.intValue());
System.out.print((++id).intValue());
Oracle Certified Professional Java Programmer
Access: Public Instant Grading
Jobilize.com uses cookies to ensure that you get the best experience. By continuing to use Jobilize.com web-site, you agree to the Terms of Use.