95
Java Collections synchronizedList() Method
The synchronizedList() method of Java Collections class is used to get a synchronized (thread-safe) collection backed by the specified list.
Syntax
Following is the declaration of synchronizedList() method:
Parameter
Parameter | Description | Required/Optional |
---|---|---|
list | It is the list which will be wrapped in a synchronized list. | Required |
Returns
The synchronizedList() method returns a synchronized view of the specified List.
Exceptions
NA
Compatibility Version
Java 1.5 and above
Example 1
Output:
Synchronized list is :[A, B, C, D, E]
Example 2
Output:
Synchronized view is :[44, 55, 99, 77, 88, 66]
Example 3
Output:
Initial size: 10000 4573
Next TopicJava Collections Class