Jump to content

Java Threads Help Needed


Recommended Posts

Posted
new Button("Generate Report").addClickListener(new Button.ClickListener() ({
         public void buttonClick(ClickEvent event) {
                new Thread(runnableObj).start();
            }
});
 
Runnable runnableObj = new Runnable{
       public void run(){
           //Report Generates here
            reportLaunch();
             if(isReportSuccessful){
                   //Saves the status of the report
                   saveReportStatus();
                }
         }
});
 
 
if i launch a report r1 (assume it takes 45 minutes to generate) and after 5 minutes i launched another report r2(assume it takes 20 mintutes to generate), when i save the report status, which report status will be saved? and will it give any concurrency conflicts? How to avoid this situation?
 
Thanks
Posted

andhuke cheppedhi chinnappudu saduvukora ani... vinnava na mata... ippudu chudu ila cnf2OV.gif

Posted

andhuke cheppedhi chinnappudu saduvukora ani... vinnava na mata... ippudu chudu ila cnf2OV.gif

 

nee bonda ra nee bonda arc team ki kuda chukkal choopistundi oka issue cnf2OV.gif

Posted

bhayya....why don't u use synchronization....so that 1st report save avudhi gaa ..

 

Suggestion wrong aithe vadhilye....just in learning stages

Posted

 

new Button("Generate Report").addClickListener(new Button.ClickListener() ({
         public void buttonClick(ClickEvent event) {
                new Thread(runnableObj).start();
            }
});
 
Runnable runnableObj = new Runnable{
       public void run(){
           //Report Generates here
            reportLaunch();
             if(isReportSuccessful){
                   //Saves the status of the report
                   saveReportStatus();
                }
         }
});
 
 
if i launch a report r1 (assume it takes 45 minutes to generate) and after 5 minutes i launched another report r2(assume it takes 20 mintutes to generate), when i save the report status, which report status will be saved? and will it give any concurrency conflicts? How to avoid this situation?
 
Thanks

 

 

isReportSuccessful true iythene status save avthundhi so eh report launch first avthadho that returns succesfull status and hence saves the status. kabati edhi first launch iythe dhani status vasthadhi ..

 

to avoid concurrency try using syncronization concept as macho said 

 

another option is use wait() and notify() concepts in thread... so that wait until report is launched and then start another report launching.. 

Posted

bhayya....why don't u use synchronization....so that 1st report save avudhi gaa ..

 

Suggestion wrong aithe vadhilye....just in learning stages

already try chesam...deadlock ayyi performance darunamga poyindi 

Posted

don't give option to same user to click 2 nd time when current report running

 

u will have memory problem 

Posted

don't give option to same user to click 2 nd time when current report running

 

u will have memory problem 

So far the system was like dis, but the user made a request to be able to generate multiple reports symultaneosly,,,how to avoid this memory prob/?

Posted

So far the system was like dis, but the user made a request to be able to generate multiple reports symultaneosly,,,how to avoid this memory prob/?

for each instance 

 

make report single thread 

 

process requests one by one

 

like

 

Add the requests to MAP

 

and process one by one

Posted

for each instance 

 

make report single thread 

 

process requests one by one

 

like

 

Add the requests to MAP

 

and process one by one

you mean to say, save the report config in static map for each onclick and to process one after one? seems gud idea will try tomorrow

Posted

you mean to say, save the report config in static map for each onclick and to process one after one? seems gud idea will try tomorrow

exactly

Posted

whatz the mistake when i use 'synchronized'

 

like

 

new Button("Generate Report").addClickListener(new Button.ClickListener() ({
         public void buttonClick(ClickEvent event) {
                new Thread(runnableObj).start();
            }
});
 
Runnable runnableObj = new Runnable{
       public void run(){
           //Report Generates here
            reportLaunch();
             if(isReportSuccessful){
                   //Saves the status of the report
                   saveReportStatus();
                }
         }
});
 
private synchronized reportLaunch(){
/* block1*..../
}
 
The threads are entering into block1 simultaneosly even its synchronized how is dat possible?
 
 
 
Posted

try this

 

publc ur method declaration(){

synchronize(MAP<Report data>) {

 

}

Posted

 

whatz the mistake when i use 'synchronized'

 

like

 

new Button("Generate Report").addClickListener(new Button.ClickListener() ({
         public void buttonClick(ClickEvent event) {
                new Thread(runnableObj).start();
            }
});
 
Runnable runnableObj = new Runnable{
       public void run(){
           //Report Generates here
            reportLaunch();
             if(isReportSuccessful){
                   //Saves the status of the report
                   saveReportStatus();
                }
         }
});
 
private synchronized reportLaunch(){
/* block1*..../
}
 
The threads are entering into block1 simultaneosly even its synchronized how is dat possible?

 

 

KK asala neeku cnf2OV.gif

Posted

try this

 

publc ur method declaration(){

synchronize(MAP<Report data>) {

 

}

thanks man

×
×
  • Create New...