-
-
Save kasramp/aee0df2ab0d2be2bf9f3685933b8d75d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThreadClass extends Thread { | |
private Thread thread; | |
private Vector<Mails> mailQueue = new Vector<Mails>(); | |
public void start(Vector<Mails> mailQueue) { | |
if (thread == null) { | |
this.mailQueue = mailQueue; | |
thread = new Thread(this); | |
thread.start(); | |
} | |
} | |
public void run() { | |
//Update share resource | |
synchronized (this) { | |
updateNoteBook(); | |
} | |
// Other operation here | |
} | |
public static synchronized updateNoteBook() { | |
// Do whatever necessary | |
// The function can be called by one thread at the same time | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment