Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using System.arraycopy to copy an array into itself.

838575Feb 10 2011 — edited Feb 10 2011
I was wondering if there are any potential problems with using code similar to below?
 System.arraycopy(Global.queueUrgent, 1, Global.queueUrgent, 0, Global.queueUrgent.length-1); 
I have an array which works as a job queue. Another thread looks at this queue and then acts on it according to the data held in Global.queueUrgent[0]. Once this task has been accomplished, the first job is removed and the rest of the queue is brought forward one (and hence the code sample).

I understand the risks of a race condition which might occur in my application and can prevent it as much as possible but I was wondering if there were any other concerns I should address. It's important that I use an array such as this for my project.

I haven't tried to implement the code as of yet as I would like to hear your thoughts on it first.

Regards,
Robert (1BillionHex).
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2011
Added on Feb 10 2011
7 comments
1,364 views