How to unify the Date(Timeline) in different threads?











up vote
-2
down vote

favorite












A Customer Generator Thread:



public class CustomerGeneratorThread implements Runnable {
private BlockingQueue<Customer> customerList;

public CustomerGeneratorThread(BlockingQueue<Customer> customerList){
this.customerList = customerList;
}

@Override
public void run() {
while(true){
//generate a new customer
Customer customer = new Customer();
customer.setArrivedTime(new Date(Sysmtem.currentTimeMillis()));
customer.setTimeOfCheckout(Math.random()*1000)
customerList.offer(customer);
}
}
}


An assigning Generator Thread:



public class AssigningThread implements Runnable {


private ArrayList<Queue<Customer>> customerWaitingLists;
private BlockingQueue<Customer> customerList;
private int numOfCheckout;

public AssigningThread(ArrayList<Queue<Customer>> customerWaitingLists, BlockingQueue<Customer> customerList, int numOfCheckout) {
this.customerWaitingLists = customerWaitingLists;
this.customerList = customerList;
this.numOfCheckout = numOfCheckout;
}


@Override
public void run() {
while (true) {
try {
Customer customerToken = customerList.take();
synchronized (customerWaitingLists) {
for (int i = 0; i < numOfCheckout; i++) {
Queue<Customer> q = customerWaitingLists.get(i);
if (q.size() < 6) {
q.offer(customerToken);
}
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

}


Several Checkout Threads:



public class CheckoutThread implements Runnable {

private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;


public CheckoutThread(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
}


@Override
public void run() {
while (true) {
Customer customerPolled;
synchronized (customerWaitingLists) {
customerPolled = (Customer) customerWaitingLists.get(numOfCheckout).poll();

customerPolled.setCheckStartTime(new Date(System.currentTimeMillis()));
Integer timeOfCheckout = customerPolled.getTimeOfCheckout();
try {
Thread.sleep(timeOfCheckout);
} catch (InterruptedException e) {
e.printStackTrace();
}
customerPolled.setCheckEndTime(new Date(System.currentTimeMillis()));
}
synchronized(customerCheckedList){
customerCheckedList.add(customerPolled);
}
}
}
}


The Customer class:



public class Customer {


private Date arrivedTime;

private Integer timeOfCheckout;

private Date checkStartTime;

private Date checkEndTime;

public Date getArrivedTime() {
return arrivedTime;
}

public void setArrivedTime(Date arrivedTime) {
this.arrivedTime = arrivedTime;
}

public Integer getTimeOfCheckout() {
return timeOfCheckout;
}

public void setTimeOfCheckout(Integer timeOfCheckout) {
this.timeOfCheckout = timeOfCheckout;
}

public Date getCheckStartTime() {
return checkStartTime;
}

public void setCheckStartTime(Date checkStartTime) {
this.checkStartTime = checkStartTime;
}

public Date getCheckEndTime() {
return checkEndTime;
}

public void setCheckEndTime(Date checkEndTime) {
this.checkEndTime = checkEndTime;
}
}


The main thread:



public class MainApp {
private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;
private BlockingQueue<Customer> customerList;

public MainApp(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList, BlockingQueue<Customer> customerList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
this.customerList = customerList;
test();
}

public void test() {
CustomerGeneratorThread cgt = new CustomerGeneratorThread(customerList);
new Thread(cgt).start();

AssigningThread at = new AssigningThread(customerWaitingLists, customerList, numOfCheckout);
new Thread(at).start();

for (int i = 0; i < numOfCheckout; i++) {
CheckoutThread ct = new CheckoutThread(numOfCheckout, customerWaitingLists, customerCheckedList);
new Thread(ct).start();
}

//sleep for 20s ,then, get wait time of each customer
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (customerCheckedList) {
for (int i = 0; i < customerCheckedList.size(); i++) {
Customer c = customerCheckedList.get(i);
long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();
System.out.println((waitTime / 1000) + " sec");
}
}
}

public static void main(String args) {
MainApp mainApp = new MainApp(5, new ArrayList<Queue<Customer>>(), new ArrayList<Customer>(), new ArrayBlockingQueue());
}

}


Here is the problem:



long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();


The waitTime sometimes was assigned to a negative number which confused me.



A customer follows the sequence like this:



CustomerGeneratorThread(setArrivedTime) -> AssigningThread -> CheckoutThread(setCheckStartTime).



At this situation, the waitTime shouldn't be a negative number.



So, how to fix this problem?



Thanks in advance.










share|improve this question




















  • 4




    I downvoted because without code, it is very hard to help you
    – Andreas
    Nov 11 at 1:23






  • 1




    Check this answer stackoverflow.com/a/30120693/1654233. Perhaps your issue is of the same nature.
    – yegodm
    Nov 11 at 3:45








  • 1




    FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
    – Basil Bourque
    Nov 11 at 4:00






  • 2




    MCVE
    – Basil Bourque
    Nov 11 at 4:05










  • There are so many ways a bug in your program could cause this, so we need to see that in order to determine whether that could be cause or the problem lies somewhere else. It will probably be a non-trivial task to produce a Minimal, Complete, and Verifiable example, but I still think it’s your best way forward with this question.
    – Ole V.V.
    Nov 11 at 6:55















up vote
-2
down vote

favorite












A Customer Generator Thread:



public class CustomerGeneratorThread implements Runnable {
private BlockingQueue<Customer> customerList;

public CustomerGeneratorThread(BlockingQueue<Customer> customerList){
this.customerList = customerList;
}

@Override
public void run() {
while(true){
//generate a new customer
Customer customer = new Customer();
customer.setArrivedTime(new Date(Sysmtem.currentTimeMillis()));
customer.setTimeOfCheckout(Math.random()*1000)
customerList.offer(customer);
}
}
}


An assigning Generator Thread:



public class AssigningThread implements Runnable {


private ArrayList<Queue<Customer>> customerWaitingLists;
private BlockingQueue<Customer> customerList;
private int numOfCheckout;

public AssigningThread(ArrayList<Queue<Customer>> customerWaitingLists, BlockingQueue<Customer> customerList, int numOfCheckout) {
this.customerWaitingLists = customerWaitingLists;
this.customerList = customerList;
this.numOfCheckout = numOfCheckout;
}


@Override
public void run() {
while (true) {
try {
Customer customerToken = customerList.take();
synchronized (customerWaitingLists) {
for (int i = 0; i < numOfCheckout; i++) {
Queue<Customer> q = customerWaitingLists.get(i);
if (q.size() < 6) {
q.offer(customerToken);
}
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

}


Several Checkout Threads:



public class CheckoutThread implements Runnable {

private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;


public CheckoutThread(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
}


@Override
public void run() {
while (true) {
Customer customerPolled;
synchronized (customerWaitingLists) {
customerPolled = (Customer) customerWaitingLists.get(numOfCheckout).poll();

customerPolled.setCheckStartTime(new Date(System.currentTimeMillis()));
Integer timeOfCheckout = customerPolled.getTimeOfCheckout();
try {
Thread.sleep(timeOfCheckout);
} catch (InterruptedException e) {
e.printStackTrace();
}
customerPolled.setCheckEndTime(new Date(System.currentTimeMillis()));
}
synchronized(customerCheckedList){
customerCheckedList.add(customerPolled);
}
}
}
}


The Customer class:



public class Customer {


private Date arrivedTime;

private Integer timeOfCheckout;

private Date checkStartTime;

private Date checkEndTime;

public Date getArrivedTime() {
return arrivedTime;
}

public void setArrivedTime(Date arrivedTime) {
this.arrivedTime = arrivedTime;
}

public Integer getTimeOfCheckout() {
return timeOfCheckout;
}

public void setTimeOfCheckout(Integer timeOfCheckout) {
this.timeOfCheckout = timeOfCheckout;
}

public Date getCheckStartTime() {
return checkStartTime;
}

public void setCheckStartTime(Date checkStartTime) {
this.checkStartTime = checkStartTime;
}

public Date getCheckEndTime() {
return checkEndTime;
}

public void setCheckEndTime(Date checkEndTime) {
this.checkEndTime = checkEndTime;
}
}


The main thread:



public class MainApp {
private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;
private BlockingQueue<Customer> customerList;

public MainApp(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList, BlockingQueue<Customer> customerList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
this.customerList = customerList;
test();
}

public void test() {
CustomerGeneratorThread cgt = new CustomerGeneratorThread(customerList);
new Thread(cgt).start();

AssigningThread at = new AssigningThread(customerWaitingLists, customerList, numOfCheckout);
new Thread(at).start();

for (int i = 0; i < numOfCheckout; i++) {
CheckoutThread ct = new CheckoutThread(numOfCheckout, customerWaitingLists, customerCheckedList);
new Thread(ct).start();
}

//sleep for 20s ,then, get wait time of each customer
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (customerCheckedList) {
for (int i = 0; i < customerCheckedList.size(); i++) {
Customer c = customerCheckedList.get(i);
long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();
System.out.println((waitTime / 1000) + " sec");
}
}
}

public static void main(String args) {
MainApp mainApp = new MainApp(5, new ArrayList<Queue<Customer>>(), new ArrayList<Customer>(), new ArrayBlockingQueue());
}

}


Here is the problem:



long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();


The waitTime sometimes was assigned to a negative number which confused me.



A customer follows the sequence like this:



CustomerGeneratorThread(setArrivedTime) -> AssigningThread -> CheckoutThread(setCheckStartTime).



At this situation, the waitTime shouldn't be a negative number.



So, how to fix this problem?



Thanks in advance.










share|improve this question




















  • 4




    I downvoted because without code, it is very hard to help you
    – Andreas
    Nov 11 at 1:23






  • 1




    Check this answer stackoverflow.com/a/30120693/1654233. Perhaps your issue is of the same nature.
    – yegodm
    Nov 11 at 3:45








  • 1




    FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
    – Basil Bourque
    Nov 11 at 4:00






  • 2




    MCVE
    – Basil Bourque
    Nov 11 at 4:05










  • There are so many ways a bug in your program could cause this, so we need to see that in order to determine whether that could be cause or the problem lies somewhere else. It will probably be a non-trivial task to produce a Minimal, Complete, and Verifiable example, but I still think it’s your best way forward with this question.
    – Ole V.V.
    Nov 11 at 6:55













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











A Customer Generator Thread:



public class CustomerGeneratorThread implements Runnable {
private BlockingQueue<Customer> customerList;

public CustomerGeneratorThread(BlockingQueue<Customer> customerList){
this.customerList = customerList;
}

@Override
public void run() {
while(true){
//generate a new customer
Customer customer = new Customer();
customer.setArrivedTime(new Date(Sysmtem.currentTimeMillis()));
customer.setTimeOfCheckout(Math.random()*1000)
customerList.offer(customer);
}
}
}


An assigning Generator Thread:



public class AssigningThread implements Runnable {


private ArrayList<Queue<Customer>> customerWaitingLists;
private BlockingQueue<Customer> customerList;
private int numOfCheckout;

public AssigningThread(ArrayList<Queue<Customer>> customerWaitingLists, BlockingQueue<Customer> customerList, int numOfCheckout) {
this.customerWaitingLists = customerWaitingLists;
this.customerList = customerList;
this.numOfCheckout = numOfCheckout;
}


@Override
public void run() {
while (true) {
try {
Customer customerToken = customerList.take();
synchronized (customerWaitingLists) {
for (int i = 0; i < numOfCheckout; i++) {
Queue<Customer> q = customerWaitingLists.get(i);
if (q.size() < 6) {
q.offer(customerToken);
}
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

}


Several Checkout Threads:



public class CheckoutThread implements Runnable {

private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;


public CheckoutThread(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
}


@Override
public void run() {
while (true) {
Customer customerPolled;
synchronized (customerWaitingLists) {
customerPolled = (Customer) customerWaitingLists.get(numOfCheckout).poll();

customerPolled.setCheckStartTime(new Date(System.currentTimeMillis()));
Integer timeOfCheckout = customerPolled.getTimeOfCheckout();
try {
Thread.sleep(timeOfCheckout);
} catch (InterruptedException e) {
e.printStackTrace();
}
customerPolled.setCheckEndTime(new Date(System.currentTimeMillis()));
}
synchronized(customerCheckedList){
customerCheckedList.add(customerPolled);
}
}
}
}


The Customer class:



public class Customer {


private Date arrivedTime;

private Integer timeOfCheckout;

private Date checkStartTime;

private Date checkEndTime;

public Date getArrivedTime() {
return arrivedTime;
}

public void setArrivedTime(Date arrivedTime) {
this.arrivedTime = arrivedTime;
}

public Integer getTimeOfCheckout() {
return timeOfCheckout;
}

public void setTimeOfCheckout(Integer timeOfCheckout) {
this.timeOfCheckout = timeOfCheckout;
}

public Date getCheckStartTime() {
return checkStartTime;
}

public void setCheckStartTime(Date checkStartTime) {
this.checkStartTime = checkStartTime;
}

public Date getCheckEndTime() {
return checkEndTime;
}

public void setCheckEndTime(Date checkEndTime) {
this.checkEndTime = checkEndTime;
}
}


The main thread:



public class MainApp {
private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;
private BlockingQueue<Customer> customerList;

public MainApp(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList, BlockingQueue<Customer> customerList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
this.customerList = customerList;
test();
}

public void test() {
CustomerGeneratorThread cgt = new CustomerGeneratorThread(customerList);
new Thread(cgt).start();

AssigningThread at = new AssigningThread(customerWaitingLists, customerList, numOfCheckout);
new Thread(at).start();

for (int i = 0; i < numOfCheckout; i++) {
CheckoutThread ct = new CheckoutThread(numOfCheckout, customerWaitingLists, customerCheckedList);
new Thread(ct).start();
}

//sleep for 20s ,then, get wait time of each customer
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (customerCheckedList) {
for (int i = 0; i < customerCheckedList.size(); i++) {
Customer c = customerCheckedList.get(i);
long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();
System.out.println((waitTime / 1000) + " sec");
}
}
}

public static void main(String args) {
MainApp mainApp = new MainApp(5, new ArrayList<Queue<Customer>>(), new ArrayList<Customer>(), new ArrayBlockingQueue());
}

}


Here is the problem:



long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();


The waitTime sometimes was assigned to a negative number which confused me.



A customer follows the sequence like this:



CustomerGeneratorThread(setArrivedTime) -> AssigningThread -> CheckoutThread(setCheckStartTime).



At this situation, the waitTime shouldn't be a negative number.



So, how to fix this problem?



Thanks in advance.










share|improve this question















A Customer Generator Thread:



public class CustomerGeneratorThread implements Runnable {
private BlockingQueue<Customer> customerList;

public CustomerGeneratorThread(BlockingQueue<Customer> customerList){
this.customerList = customerList;
}

@Override
public void run() {
while(true){
//generate a new customer
Customer customer = new Customer();
customer.setArrivedTime(new Date(Sysmtem.currentTimeMillis()));
customer.setTimeOfCheckout(Math.random()*1000)
customerList.offer(customer);
}
}
}


An assigning Generator Thread:



public class AssigningThread implements Runnable {


private ArrayList<Queue<Customer>> customerWaitingLists;
private BlockingQueue<Customer> customerList;
private int numOfCheckout;

public AssigningThread(ArrayList<Queue<Customer>> customerWaitingLists, BlockingQueue<Customer> customerList, int numOfCheckout) {
this.customerWaitingLists = customerWaitingLists;
this.customerList = customerList;
this.numOfCheckout = numOfCheckout;
}


@Override
public void run() {
while (true) {
try {
Customer customerToken = customerList.take();
synchronized (customerWaitingLists) {
for (int i = 0; i < numOfCheckout; i++) {
Queue<Customer> q = customerWaitingLists.get(i);
if (q.size() < 6) {
q.offer(customerToken);
}
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

}


Several Checkout Threads:



public class CheckoutThread implements Runnable {

private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;


public CheckoutThread(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
}


@Override
public void run() {
while (true) {
Customer customerPolled;
synchronized (customerWaitingLists) {
customerPolled = (Customer) customerWaitingLists.get(numOfCheckout).poll();

customerPolled.setCheckStartTime(new Date(System.currentTimeMillis()));
Integer timeOfCheckout = customerPolled.getTimeOfCheckout();
try {
Thread.sleep(timeOfCheckout);
} catch (InterruptedException e) {
e.printStackTrace();
}
customerPolled.setCheckEndTime(new Date(System.currentTimeMillis()));
}
synchronized(customerCheckedList){
customerCheckedList.add(customerPolled);
}
}
}
}


The Customer class:



public class Customer {


private Date arrivedTime;

private Integer timeOfCheckout;

private Date checkStartTime;

private Date checkEndTime;

public Date getArrivedTime() {
return arrivedTime;
}

public void setArrivedTime(Date arrivedTime) {
this.arrivedTime = arrivedTime;
}

public Integer getTimeOfCheckout() {
return timeOfCheckout;
}

public void setTimeOfCheckout(Integer timeOfCheckout) {
this.timeOfCheckout = timeOfCheckout;
}

public Date getCheckStartTime() {
return checkStartTime;
}

public void setCheckStartTime(Date checkStartTime) {
this.checkStartTime = checkStartTime;
}

public Date getCheckEndTime() {
return checkEndTime;
}

public void setCheckEndTime(Date checkEndTime) {
this.checkEndTime = checkEndTime;
}
}


The main thread:



public class MainApp {
private int numOfCheckout;
private ArrayList<Queue<Customer>> customerWaitingLists;
private ArrayList<Customer> customerCheckedList;
private BlockingQueue<Customer> customerList;

public MainApp(int numOfCheckout, ArrayList<Queue<Customer>> customerWaitingLists, ArrayList<Customer> customerCheckedList, BlockingQueue<Customer> customerList) {
this.numOfCheckout = numOfCheckout;
this.customerWaitingLists = customerWaitingLists;
this.customerCheckedList = customerCheckedList;
this.customerList = customerList;
test();
}

public void test() {
CustomerGeneratorThread cgt = new CustomerGeneratorThread(customerList);
new Thread(cgt).start();

AssigningThread at = new AssigningThread(customerWaitingLists, customerList, numOfCheckout);
new Thread(at).start();

for (int i = 0; i < numOfCheckout; i++) {
CheckoutThread ct = new CheckoutThread(numOfCheckout, customerWaitingLists, customerCheckedList);
new Thread(ct).start();
}

//sleep for 20s ,then, get wait time of each customer
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (customerCheckedList) {
for (int i = 0; i < customerCheckedList.size(); i++) {
Customer c = customerCheckedList.get(i);
long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();
System.out.println((waitTime / 1000) + " sec");
}
}
}

public static void main(String args) {
MainApp mainApp = new MainApp(5, new ArrayList<Queue<Customer>>(), new ArrayList<Customer>(), new ArrayBlockingQueue());
}

}


Here is the problem:



long waitTime = c.getCheckStartTime().getTime() - c.getArrivedTime().getTime();


The waitTime sometimes was assigned to a negative number which confused me.



A customer follows the sequence like this:



CustomerGeneratorThread(setArrivedTime) -> AssigningThread -> CheckoutThread(setCheckStartTime).



At this situation, the waitTime shouldn't be a negative number.



So, how to fix this problem?



Thanks in advance.







java multithreading date time






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 13:42

























asked Nov 11 at 1:12









Arthur Chen

32




32








  • 4




    I downvoted because without code, it is very hard to help you
    – Andreas
    Nov 11 at 1:23






  • 1




    Check this answer stackoverflow.com/a/30120693/1654233. Perhaps your issue is of the same nature.
    – yegodm
    Nov 11 at 3:45








  • 1




    FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
    – Basil Bourque
    Nov 11 at 4:00






  • 2




    MCVE
    – Basil Bourque
    Nov 11 at 4:05










  • There are so many ways a bug in your program could cause this, so we need to see that in order to determine whether that could be cause or the problem lies somewhere else. It will probably be a non-trivial task to produce a Minimal, Complete, and Verifiable example, but I still think it’s your best way forward with this question.
    – Ole V.V.
    Nov 11 at 6:55














  • 4




    I downvoted because without code, it is very hard to help you
    – Andreas
    Nov 11 at 1:23






  • 1




    Check this answer stackoverflow.com/a/30120693/1654233. Perhaps your issue is of the same nature.
    – yegodm
    Nov 11 at 3:45








  • 1




    FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
    – Basil Bourque
    Nov 11 at 4:00






  • 2




    MCVE
    – Basil Bourque
    Nov 11 at 4:05










  • There are so many ways a bug in your program could cause this, so we need to see that in order to determine whether that could be cause or the problem lies somewhere else. It will probably be a non-trivial task to produce a Minimal, Complete, and Verifiable example, but I still think it’s your best way forward with this question.
    – Ole V.V.
    Nov 11 at 6:55








4




4




I downvoted because without code, it is very hard to help you
– Andreas
Nov 11 at 1:23




I downvoted because without code, it is very hard to help you
– Andreas
Nov 11 at 1:23




1




1




Check this answer stackoverflow.com/a/30120693/1654233. Perhaps your issue is of the same nature.
– yegodm
Nov 11 at 3:45






Check this answer stackoverflow.com/a/30120693/1654233. Perhaps your issue is of the same nature.
– yegodm
Nov 11 at 3:45






1




1




FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
– Basil Bourque
Nov 11 at 4:00




FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
– Basil Bourque
Nov 11 at 4:00




2




2




MCVE
– Basil Bourque
Nov 11 at 4:05




MCVE
– Basil Bourque
Nov 11 at 4:05












There are so many ways a bug in your program could cause this, so we need to see that in order to determine whether that could be cause or the problem lies somewhere else. It will probably be a non-trivial task to produce a Minimal, Complete, and Verifiable example, but I still think it’s your best way forward with this question.
– Ole V.V.
Nov 11 at 6:55




There are so many ways a bug in your program could cause this, so we need to see that in order to determine whether that could be cause or the problem lies somewhere else. It will probably be a non-trivial task to produce a Minimal, Complete, and Verifiable example, but I still think it’s your best way forward with this question.
– Ole V.V.
Nov 11 at 6:55

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244975%2fhow-to-unify-the-datetimeline-in-different-threads%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244975%2fhow-to-unify-the-datetimeline-in-different-threads%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values