Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ccbfb45

Browse files
Experiment 9_3
1 parent 115eb12 commit ccbfb45

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎Experiment 9/Exp9_3.java‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//package thread;
2+
class counter {
3+
Integer count = 0;
4+
5+
public void increament() {
6+
count++;
7+
}
8+
}
9+
public class Exp9_3 {
10+
public static void main(String[] args) throws Exception {
11+
counter c = new counter();
12+
Thread t1 = new Thread(new Runnable() {
13+
public void run() {
14+
for (Integer i = 0; i < 1000; i++) {
15+
c.increament();
16+
}
17+
}
18+
});
19+
t1.start();
20+
t1.join();
21+
System.out.println(c.count);
22+
}
23+
24+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /