It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

Java's synchronised keyword

page: 1
1

log in

join
share:

posted on Mar, 9 2023 @ 12:06 AM
link   
Using the synchronised keyword in Java does not produce the desired results.

I attempted to build thread synchronisation in Java using the synchronised keyword, but I am not receiving the intended results. Variable cnt should have a final value of 20,000, however this is not the case.




package MultiThreading;


class Runner extends Thread [

private static int cnt=0;

public synchronized void func() [
cnt++;
]

public void run() [
for(int i=0; i



new topics
 
1

log in

join