Solved

Threads.

Posted on 2004-10-01
23
302 Views
Last Modified: 2010-03-31
Is there any difference for the calling class, in run()ning a Runnable, or start()ing a Thread? By which I mean, is there any difference in the conditions under which control returns to the calling class between a Thread and a Runnable.
0
Comment
Question by:krakatoa
  • 11
  • 7
  • 5
23 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 12198016
Nope
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12198018
Because you have to add a Runnable to a Thread, which is basically the same as subclassing a Thread and running it
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12198023
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

Expert Comment

by:TimYates
ID: 12198028
And if you are using Java 1.5, there are the new Executor classes as well :-)

http://www.ftponline.com/javapro/2004_08/online/bgoetz_08_04_04/
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12198031
Nothing to add to that beyond chipping in with something irrelevant - done much JSF yet Tim? (sorry krak ;-))
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12198037
Not yet...it's on my list of things to do, but I haven't got past Struts at the moment :-/  Any good?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12198068
Actually i *do* have something to add: it's acctually better for design reasons to use Runnable, as, for reasons i'm not going into now, it's better to use interfaces than to create subclasses. So prefer implements Runnable over extends Thread

>>Any good?

Well i was hoping you could tell me - perhaps we'd better continue this (briefly) offline? c j AT p r o t e a n i t DOT n e t
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12198116
OK - I was asking mostly for return of control reasons, as I said, but also to remind myself (lol), why I'd done this :

Thread fileProcessThread = new Thread(new USender(filetogo));

instead of

Runnable fileProcessThread = new Runnable(new USender(filetogo));

where USender is a class implementing Runnable.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 50 total points
ID: 12198140
Well of course

>>Runnable fileProcessThread = new Runnable(new USender(filetogo));

would be invalid.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12198203
8-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12198242
:-)
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12216385
Hey Tim!

(looks like I caught the "second-agenda" bug from CEHJ  : ))      ) ......


I don't know if you recall a longish time ago now I was looking around for people to help on a few things with an IM client I was putting together. You expressed some interest, but laughed at the port / firewall conundrum that you would face if you attempted to run it - which was fine and understandable, and it was left there.

I just wanted to ask you now though, since you are behind those firewalls, if you might have any idea about how I would go about getting my app working in a typical commercial environment with similar security / firewall restrictions, in case one day the app ends up in such a setting. Would I need proxies, or ... well... I can't guess really. Any thoughts you might have would be much appreciated ....

And I am still developing it BTW (;)) , kicking it around with one or two programmers now and again ... ;)

(Sorry about the "mini-spam" from this CEHJ ) ;)

and thanks Tim. ;).
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12216452
( You must need some relief from your DNA layout manager by now !? ;))  )
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12216523
I think what you would need, is for your IM application to have the ability to connect on Port 80 (instead of the usual port you are using).

This would mean that you would need to run a public proxy on port 80 at some publically available address...  This could either be a standalone server, or a servlet.  Then, the end user would fire up their IM, it would connect to the servlet, and the servlet would connect them to the chat server (and pass-through any data sent to or from the client straight to the correct client, or the server)

then I believe it all should work (as port 80 is usually open)...  The only problem you may then hit is that some people (here included) have web monitoring/blocking software installed, so the packets may get blocked if the IT admin staff believe them to be bad/non work related...

But that's another story, and there's not much you can do about that...

>  You must need some relief from your DNA layout manager by now !? ;))

Hehehe, ta ;-)  Yeah, got all that finished, and wrapped up as a JComponent/JavaTag so I can just embed it into JSPs as I fancy :-)  Now time to write the Hibernate layer for our big sequence alignment database :-)  (and see how Hibernate copes with it before possibly scrapping it and going for plain SQL) :-D ;-)

Hope I helped a bit?

Tim
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12216660
>> Hope I helped a bit?  ...

of course you did; many thanks.

It's not an area I have ever delved into (proxies et al I mean) but then again, I know so little anyway that I could say that about most things I do. LOL! ;)

For one thing, I assume you mean a publicly available proxy being a server / let outside of the 'client's' space? If it were a servlet, I further assume you mean that it would do some translation of clients' requests and ensure they go to the right port(s) on the IM server?

Ooh , sheep and lambs and hanging ! .... could a similar thing be done straight from the IM server itself by recoding to do "http tunnelling" - or am I just using jargon I don't understand ? lol.
Good to hear about your work.


thanks again

k.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12216694
HttpTunneling is exactly what the servlet would do :-)

> For one thing, I assume you mean a publicly available proxy being a server / let outside of the 'client's' space?

Yeah, so hosted by you, allowing IM instances to connect to it on Port 80 :-)

I only suggested a servlet, as you may already have a webserver running on port 80 of your machine, so putting a servlet into it would be less hassle (perhaps) ;-)

If this is not the case, then maybe the IM server could listen on port 80?
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12216952
>> If this is not the case, then maybe the IM server could listen on port 80? ...

I guess it could, indeed.

(I already have visions of bedlam when I think about the amount of redirection I'd need to do though).

I have to start to look at it, because it seems it would be a requirement. Thanks for all your help; maybe I can repay you a little by giving some of my DNA to play with? Nah ... if you've got a nematode lying around somewhere, you can get the same from it instead. ;))

Best regs

k.

CEHJ : - To make up for the spam , and as I see you like chat clients, please feel free to have a go with mine ! Ha, ha! ;)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12216964
> if you've got a nematode lying around somewhere, you can get the same from it instead. ;))

Hehehehehe! :-D

Good luck with it! :-D

Tim
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12230343
Tim .....   (he said, speaking softly and in whispers (so that's really quiet)),

I don't suppose sometime, somehow, or other, you be willing, even able, to take a shuftee at my app with us by chance? I'd really truly appreciate your thoughts on what you see and what it does as I know how skilled you are in this whole science, and its many arts. ;)

I have been on and off using it with our mutual friend (the one above in this present Question, y'know, he of #2 fame) ;) It would be really great if you could spare a half hour sometime or other!

I have a 'publicly available' point of contact, viz: wwwDOTfuturemindsDOTcom if you like.

Otherwise, thanks v much again, and kind regards.

k.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12235398
Yeah sure :-)  I'm a bit busy at the moment though, trying to get another website launched (and hibernate is playing silly buggers) ;-) But I'll try and help if I can :-D

Email sent :-)

Tim
0
 
LVL 16

Author Comment

by:krakatoa
ID: 12235514
:) ... Ok Tim ... anytime will do!

rgs.,

k.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12235798
Are you still in the middle of your Hibernate snafu Tim or are you there? ;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12236057
Hehe, had to move back to bugfixing the other webapp...  Mmmmm...DHTML and applets...  

I think my brain is about to leak out of my head ;-)  

Hibernate to javascript to servlet comms in 30 minutes == mind boggling ;-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why cannot we forward request once the response is committed 2 46
diffSum example 4 50
couple of eclipse 5 46
type mismatch (Object[] to double[] 4 33
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question