How to make a method thread safe without using synchronized
keyword?

Answer Posted / venkat

Hi Jitender,

Here the scnroniziation is happening in methodA(){}
But the same thread(Thread-0) is executing even second time
also. Could you please clarify the same.

Here is the output.

Constructor..
Thread started..Thread-0
processing....Thread-0
Thread started..Thread-1
complete..Thread-0
processing....Thread-0
complete..Thread-0

Regards,
Venkat

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?

1823


Is java pass by value or pass by reference?

532


What is jit and its use?

574


Can interface be private in java?

540


What does t in java mean?

530






Is a method a procedure?

546


What is the order of arraylist in java?

601


What happens when a thread cannot acquire a lock on an object in java programming?

540


What is a class in java?

573


How to display arraylist values in java?

479


What is the use of string and stringbuffer?

541


Which package has light weight components in java programming?

670


Can you achieve runtime polymorphism by data members?

573


What is the purpose of javac exe?

555


Why java applets are more useful for intranets as compared to internet?

575