Click here to Skip to main content
15,513,571 members
Home / Discussions / Java
   

Java

 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
LOKENDRA YADAV15-Jul-17 23:28
LOKENDRA YADAV15-Jul-17 23:28 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard MacCutchan16-Jul-17 2:29
mveRichard MacCutchan16-Jul-17 2:29 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
LOKENDRA YADAV16-Jul-17 3:42
LOKENDRA YADAV16-Jul-17 3:42 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard MacCutchan16-Jul-17 3:45
mveRichard MacCutchan16-Jul-17 3:45 
SuggestionRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard Deeming17-Jul-17 2:30
mveRichard Deeming17-Jul-17 2:30 
Questionvideo tracking Pin
Member 129924425-Jul-17 19:12
Member 129924425-Jul-17 19:12 
AnswerRe: video tracking Pin
Django_Untaken5-Jul-17 20:30
Django_Untaken5-Jul-17 20:30 
QuestionObserver Pattern - Restart Thread Again When Exception Occurs Pin
Django_Untaken5-Jul-17 9:52
Django_Untaken5-Jul-17 9:52 
Hello there. I am trying to implement Observer Pattern. I get notified, successfully, whenever a thread completes. I can start the same thread again when I get notified (through TaskListener I have implemented). But how do I start it again if there was some exception? Example
static MyWork objMyWork = null; // implements Runnable
static Thread objThread = null;

public static void main(String[] args) throws
{
	TaskListener listener = new TaskListener()
        {
		@Override
		public void threadComplete()
		{
			try
			{
				objMyWork = new MyWork();
				objMyWork.SetData1(int data);
				objMyWork.SetData2(String data);
				objMyWork.addListener(this);
	
				objThread = new Thread(objMyWork);
				objThread.start();
				objThread.join();				
			}
			catch(Exception ex)
			{
                             /*       HERE I WANT TO START THREAD AGAIN      */
			}
		}
        }

	objMyWork = new MyWork();
	objMyWork.SetData1(int data);
	objMyWork.SetData2(String data);
	objMyWork.addListener(listener);
	
	objThread = new Thread(objMyWork);
	objThread.start();
	objThread.join();
}

1- What changes do I make in MyWork so that control always comes back in the
catch section of TaskListener::threadComplete() whenever there was exception?

2- Once control is there, how do I start this thread again (I dont want to nest another try-catch block and then another in the nested one and then another .... and so on).

Thanks for anything you share Smile | :)
AnswerRe: Observer Pattern - Restart Thread Again When Exception Occurs Pin
Richard MacCutchan5-Jul-17 22:55
mveRichard MacCutchan5-Jul-17 22:55 
QuestionNo value specified for parameter 2 Pin
karengsh3-Jul-17 6:27
karengsh3-Jul-17 6:27 
AnswerRe: No value specified for parameter 2 Pin
Richard Deeming3-Jul-17 6:29
mveRichard Deeming3-Jul-17 6:29 
GeneralRe: No value specified for parameter 2 Pin
karengsh3-Jul-17 6:33
karengsh3-Jul-17 6:33 
GeneralRe: No value specified for parameter 2 Pin
Richard Deeming3-Jul-17 8:06
mveRichard Deeming3-Jul-17 8:06 
GeneralRe: No value specified for parameter 2 Pin
karengsh3-Jul-17 17:33
karengsh3-Jul-17 17:33 
GeneralRe: No value specified for parameter 2 Pin
Richard MacCutchan3-Jul-17 22:20
mveRichard MacCutchan3-Jul-17 22:20 
GeneralRe: No value specified for parameter 2 Pin
karengsh4-Jul-17 6:51
karengsh4-Jul-17 6:51 
GeneralRe: No value specified for parameter 2 Pin
LynxEffect9-Aug-17 10:56
LynxEffect9-Aug-17 10:56 
Questionusing firefox progmatically with java Pin
Member 132904603-Jul-17 3:45
Member 132904603-Jul-17 3:45 
AnswerRe: using firefox progmatically with java Pin
Richard MacCutchan3-Jul-17 4:22
mveRichard MacCutchan3-Jul-17 4:22 
Questionjava.net.SocketException: Software caused connection abort: socket write error Pin
Django_Untaken1-Jul-17 10:57
Django_Untaken1-Jul-17 10:57 
GeneralRe: java.net.SocketException: Software caused connection abort: socket write error Pin
Richard MacCutchan1-Jul-17 21:53
mveRichard MacCutchan1-Jul-17 21:53 
GeneralRe: java.net.SocketException: Software caused connection abort: socket write error Pin
Django_Untaken2-Jul-17 0:39
Django_Untaken2-Jul-17 0:39 
GeneralRe: java.net.SocketException: Software caused connection abort: socket write error Pin
Richard MacCutchan2-Jul-17 2:37
mveRichard MacCutchan2-Jul-17 2:37 
GeneralRe: java.net.SocketException: Software caused connection abort: socket write error Pin
Django_Untaken2-Jul-17 8:33
Django_Untaken2-Jul-17 8:33 
GeneralRe: java.net.SocketException: Software caused connection abort: socket write error Pin
Richard MacCutchan3-Jul-17 4:23
mveRichard MacCutchan3-Jul-17 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.