-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u212
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
when trying to add() and poll() in two different threads at same time poll method not giving any return value also some times add method will be stops.Taking 3x times for popping compare to add.
---------- BEGIN SOURCE ----------
import java.util.LinkedList;
import java.util.Queue;
public class Vectorr {
static long addlong=0;
static long polllong=0;
Queue<Long> q = new LinkedList<>();
public static void main(String[] args)throws Exception {
Vectorr que=new Vectorr();
new Thread(){
@Override
public void run() {
while(true)
{
System.out.println("Adding to q "+addlong++);
que.add(addlong);
//Thread.sleep(1);
}
}
}.start();
new Thread(){
@Override
public void run() {
while(true)
{
polllong=que.poll();
System.out.println("poll from q "+polllong);
//Thread.sleep(1);
}
}
}.start();
}
void add(long i)
{
q.add(i);
}
Long poll()
{
return q.poll();
}
}
---------- END SOURCE ----------
FREQUENCY : always
when trying to add() and poll() in two different threads at same time poll method not giving any return value also some times add method will be stops.Taking 3x times for popping compare to add.
---------- BEGIN SOURCE ----------
import java.util.LinkedList;
import java.util.Queue;
public class Vectorr {
static long addlong=0;
static long polllong=0;
Queue<Long> q = new LinkedList<>();
public static void main(String[] args)throws Exception {
Vectorr que=new Vectorr();
new Thread(){
@Override
public void run() {
while(true)
{
System.out.println("Adding to q "+addlong++);
que.add(addlong);
//Thread.sleep(1);
}
}
}.start();
new Thread(){
@Override
public void run() {
while(true)
{
polllong=que.poll();
System.out.println("poll from q "+polllong);
//Thread.sleep(1);
}
}
}.start();
}
void add(long i)
{
q.add(i);
}
Long poll()
{
return q.poll();
}
}
---------- END SOURCE ----------
FREQUENCY : always