Hello Friends,
I have 6 to 7 threads which are running parallely. Thing is I have to put Thread.Sleep() between each threads. How Can I optimize it?
else if (__selectedString.equals("Master DataInput")) {
try {
if (RecordStore.listRecordStores() != null) {
System.out.println("IT FOUND RECORDSTORE ......");
RecordStore.deleteRecordStore("Company");
RecordStore.deleteRecordStore("Product");
RecordStore.deleteRecordStore("Model");
RecordStore.deleteRecordStore("Customer");
RecordStore.deleteRecordStore("Sales");
System.out.println("Delete All RecordStore");
} else {
System.out.println("IT NOT FOUND RECORD STORE");
}
} catch (Exception e) {
e.printStackTrace();
}
sync_company scompany = new sync_company(this);
scompany.sync_start_compnay();
try {
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
sync_Product sProduct = new sync_Product(this);
sProduct.sync_Product();
try {
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
sync_Model obj_sync_model = new sync_Model(this);
obj_sync_model.sync_model_start();
try {
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
sync_customer obj_sync_customer = new sync_customer(this);
obj_sync_customer.sync_customer_start();
try {
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
sync_Sales obj_sync_sales = new sync_Sales(this);
obj_sync_sales.sync_sales_start();
try {
Thread.sleep(2000);
alert_master = new Alert("Master DataInput", "DONE SUCESSFULLY", null, AlertType.INFO);
alert_master.setTimeout(1000);
switchDisplayable(
alert_master, Menu_List);
} catch (Exception e) {
e.printStackTrace();
}
// write post-action user code here
}
Here the thing is we are using Wait Screen of NetBeans. From this window is coming out even though data is importing. we tried Thread.Alive() function for each thread. That was worst case that not working at all. How can I optimize code??
This code is working but thing is its not optimized.
Thank You,
Hakoo Desai.