Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Lesson2 {
- private static int i;
- public static void main(String[] args) {
- Thread t1 = new Thread(new Thread2());
- Thread t2 = new Thread(new Thread2());
- t1.start();
- t2.start();
- try {
- t1.join();
- t2.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println(i);
- }
- static void incr() {
- i++;
- }
- }
- class Thread2 implements Runnable {
- @Override
- public void run() {
- synchronized ( ЧТО ТУТ ПИСАТЬ??? ) {
- for(int i=0; i<2000; i++) {
- Lesson2.incr();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment