Многопоточность и параллелизм. Изучение способов построения многопотоковых приложений, страница 2

                                File file = save.getSelectedFile();

                   FileOutputStream outfile = new FileOutputStream(file);

                   ObjectOutputStream outobj = new ObjectOutputStream(outfile);

                                outobj.writeObject(listProduct);

                   reloadList();   

                          }  catch (IOException ex) {

                                // TODO Auto-generated catch block

                                ex.printStackTrace();

                          }

            }

             }

      }

Button buttonSave = new Button("Save as...");

              buttonSave.addMouseListener(new MouseAdapter() {

                   @Override

                   public void mouseClicked(MouseEvent e) {

                         myThread mT = new myThread();

                         mT.start();

                         mT = null;

                   }

              });

Результаты работы программы:

1.  Save...

2.  Open…

Документация

Class GUIMainForm.myRunnable

·  java.lang.Object

·   

·  Lab_7.GUIMainForm.myRunnable

·  All Implemented Interfaces:

java.lang.Runnable

Enclosing class:

GUIMainForm


public class GUIMainForm.myRunnable
extends java.lang.Object
implements java.lang.Runnable

·   

·  Constructor Summary

Constructors 

Constructor and Description

GUIMainForm.myRunnable() 

·  Method Summary

Methods 

Modifier and Type

Method and Description

void

run() 

·  Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

·   

·  Constructor Detail

·  GUIMainForm.myRunnable

public GUIMainForm.myRunnable()

·  Method Detail

·  run

public void run()

Specified by:

run in interface java.lang.Runnable

Class GUIMainForm.myThread

·  java.lang.Object

·   

·  java.lang.Thread

·   

·  Lab_7.GUIMainForm.myThread

·  All Implemented Interfaces:

java.lang.Runnable

Enclosing class:

GUIMainForm


public class GUIMainForm.myThread
extends java.lang.Thread

·   

·  Nested Class Summary

·  Nested classes/interfaces inherited from class java.lang.Thread

java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler

·  Field Summary

·  Fields inherited from class java.lang.Thread

MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY

·  Constructor Summary

Constructors 

Constructor and Description

GUIMainForm.myThread() 

·  Method Summary

Methods 

Modifier and Type

Method and Description

void

run() 

·  Methods inherited from class java.lang.Thread

activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield

·  Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

·   

·  Constructor Detail

·  GUIMainForm.myThread

public GUIMainForm.myThread()

·  Method Detail

·  run

public void run()

Specified by:

run in interface java.lang.Runnable

Overrides:

run in class java.lang.Thread

Заключение

В ходе выполнения лабораторной работы были изучены и освоены способы построения многопотоковых приложений. Так же была освоены базовые средства и возможности синхронизации потоков.