678 |
|
} |
679 |
|
} |
680 |
|
|
681 |
– |
/** |
682 |
– |
* Returns an array containing all of the elements in this queue. |
683 |
– |
* The returned array elements are in no particular order. |
684 |
– |
* |
685 |
– |
* <p>The returned array will be "safe" in that no references to it are |
686 |
– |
* maintained by this queue. (In other words, this method must allocate |
687 |
– |
* a new array). The caller is thus free to modify the returned array. |
688 |
– |
* |
689 |
– |
* <p>This method acts as bridge between array-based and collection-based |
690 |
– |
* APIs. |
691 |
– |
* |
692 |
– |
* @return an array containing all of the elements in this queue |
693 |
– |
*/ |
694 |
– |
public Object[] toArray() { |
695 |
– |
final ReentrantLock lock = this.lock; |
696 |
– |
lock.lock(); |
697 |
– |
try { |
698 |
– |
return Arrays.copyOf(queue, size); |
699 |
– |
} finally { |
700 |
– |
lock.unlock(); |
701 |
– |
} |
702 |
– |
} |
703 |
– |
|
681 |
|
public String toString() { |
682 |
|
final ReentrantLock lock = this.lock; |
683 |
|
lock.lock(); |
752 |
|
} finally { |
753 |
|
lock.unlock(); |
754 |
|
} |
755 |
+ |
} |
756 |
+ |
|
757 |
+ |
/** |
758 |
+ |
* Returns an array containing all of the elements in this queue. |
759 |
+ |
* The returned array elements are in no particular order. |
760 |
+ |
* |
761 |
+ |
* <p>The returned array will be "safe" in that no references to it are |
762 |
+ |
* maintained by this queue. (In other words, this method must allocate |
763 |
+ |
* a new array). The caller is thus free to modify the returned array. |
764 |
+ |
* |
765 |
+ |
* <p>This method acts as bridge between array-based and collection-based |
766 |
+ |
* APIs. |
767 |
+ |
* |
768 |
+ |
* @return an array containing all of the elements in this queue |
769 |
+ |
*/ |
770 |
+ |
public Object[] toArray() { |
771 |
+ |
final ReentrantLock lock = this.lock; |
772 |
+ |
lock.lock(); |
773 |
+ |
try { |
774 |
+ |
return Arrays.copyOf(queue, size); |
775 |
+ |
} finally { |
776 |
+ |
lock.unlock(); |
777 |
+ |
} |
778 |
|
} |
779 |
|
|
780 |
|
/** |