Java 如何将数组添加到队列中?

Java 如何将数组添加到队列中?,java,arrays,multithreading,queue,Java,Arrays,Multithreading,Queue,是否可以将数组添加到ConcurrentLinkedQueue?如果是这样的话,.add语句会是什么样子 这是与家庭作业相关的,但是,我的整个程序旨在对MyObjects执行计算(MyObjects的默认构造函数生成随机值以对其执行大量计算) 例如: //Note: I couldn't use the Diamond Braces for the Queue-type when posing this question ConcurrentLinkedQueue theLinkedQueue

是否可以将数组添加到
ConcurrentLinkedQueue
?如果是这样的话,
.add
语句会是什么样子

这是与家庭作业相关的,但是,我的整个程序旨在对
MyObjects
执行计算(MyObjects的默认构造函数生成随机值以对其执行大量计算)

例如:

//Note: I couldn't use the Diamond Braces for the Queue-type when posing this question

ConcurrentLinkedQueue theLinkedQueue {MyObjects[]} = 
                 new ConcurrentLinkedQueue{MyObjects[]}();

MyObjects[] theArray = null;

for(int i = 0; i < 100; i++){
   theArray = new MyObjects[CONSTANT_SIZE]; 
   theLinkedQueue.add(theArray(objparameter1, objparameter2));
}
//注意:提出此问题时,我无法将菱形大括号用于队列类型
ConcurrentLinkedQueue链接队列{MyObject[]}=
新的ConcurrentLinkedQueue{MyObjects[]}();
MyObjects[]数组=null;
对于(int i=0;i<100;i++){
theArray=新对象[恒定大小];
add(数组(objparameter1,objparameter2));
}
该程序实现了多线程,在我的线程类中,我已经将
队列
传递到
构造函数
,并试图获取
MyObject
临时指向的
MyObject
数组,但到目前为止,我只能一次将一个
MyObject
添加到我的
队列
,并将其拉出。我希望能够添加与单个组件相同数量的
myObject
,而不是单独添加。我尝试了几行代码,仅针对NetBeans IDE推荐了一种抛出
不支持操作异常的方法。如何将数组添加到我的
ConcurrentLinkedQueue


(如果我的问题很难回答或让人困惑,也请道歉,第一次在这里发布)

队列声明的正确语法是:

ConcurrentLinkedQueue<MyObjects> theLinkedQueue = new ConcurrentLinkedQueue<>();
ConcurrentLinkedQueue链接队列=新建ConcurrentLinkedQueue();

从这开始,看看事情是如何发展的。

我找到了解决方案,只需添加数组,而不包括“objparameters”

theLinkedQueue.add(a);  //where a was a 'MyObject' array.
我假设您必须为每个数组索引加载要传递的参数,这似乎很愚蠢