Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java How Multiple instances of SwingWorker runs parallel with GUI processes

 
Muhammad Asghar
Greenhorn
Posts: 6
Firefox Browser Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java How Multiple instances of SwingWorker runs parallel with GUI processes

I have a class, FileTransfer which extends SwingWorker. I am creating an object of FileTransfer on button click event and execute the fileTransfer Threaed and it runs doInBackground() method of
FileTransfer which starts the file trasfter process , in case of multiple files or big file I select another source to trasfter the file, FileTrasfer new instace is created but it will not work because of SwingWorker thread is already in running , My problem is that I want to execute seprate thread on button click using Swing Worker because I have currently working in Desktop GUI if we use our own Thread class then GUI Process and Background Process does not work properly, So I want a solution in which Multiple SwingWorker instance run parallel so GUI process will not disturb.
here given template how I am working ….
Public void actionPerformed(ActionEvent ae)
{
If(ae.getActionCommand == “FileTransfter”)
{
FileTransfer fileTransfer = new FileTransfer();
fileTransfer.execute();
}
}

class FileTransfer extends SwingWorker
{
public Boolean fileTransfer()
{
// File Transfer code is here…
}
protected Object doInBackground() throws Exception
{
fileTransfer ();
return null;
}
}

Thanks..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!