Skip to content

Commit 967f6ad

Browse files
committed
Synchronized threading
1 parent 72ba2c0 commit 967f6ad

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Thread_Synchronized/sync.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import com.sun.source.tree.SynchronizedTree;
2+
3+
public class sync {
4+
static void main() {
5+
Count C = new Count();
6+
7+
Thread t1 = new Thread(C);
8+
Thread t2 = new Thread(C);
9+
10+
t1.start();
11+
t2.start();
12+
}
13+
}
14+
class Count implements Runnable{
15+
@Override
16+
public synchronized void run(){
17+
int count = 0;
18+
for(int i=0;i<1000;i++){
19+
count++;
20+
}
21+
System.out.println(count);
22+
23+
}
24+
25+
}

0 commit comments

Comments
 (0)