|
I'm teaching myself Java with one of the "Teach Yourself Java..." books, and I'm up to the chapter on Threads. I want to be sure I understand the concept properly. Is it safe to say that
first you start the thread
which then calls the run() method
which houses the actual method you want to be threaded?
Please let me know if I have this concept correct. Thanks
Dre---
|
|
|
|
|
correct.
|
|
|
|
|
Hi,
I've an aplication client-server, and I need to do an event in the client when one variable is modified in the server. it is posible???
I know that in the server or in the client is posible with propertychangelistener, but I don't know if it is posible by this way and how can I do it.
Thank you, so much
|
|
|
|
|
|
If I understood good your answer, I can't implement this, becouse I receive the comunication when the client press a button, but this button only press one client, and not all the client. However, to finish the program I need send an message to all client, but if only press the button one client only receive the message this client and not all.
Thank you so much, if I wrong, please check me
|
|
|
|
|
There is no reason this can not work, it does on a lot of software.
Is the sequence this:
0. A client initiates an action.
1. The action is sent to the server for processing.
2. All clients receive an update with the result.
This is a very simple pattern, think live chat rooms via instant messaging.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Yes, you are right, but I receive the message from the server in the event of press this button, and not all the client press the button.
I need an event that run automatic when a value change in the server, becouse not all the client will receive the value changed.
|
|
|
|
|
a Listener implementation works both ways. You can have events launched by a client that the server reacts on. And you can have actions the Server launches and one or all client react on.
In the consequence you can also have a client launching an event that causes the server to launch an event that all clients react on.
Try first to implement some listener action from server to client and vis-a-vis (a console print out should be enough to see if the server(/client ack the event).
After that connect the two listener methods and see what fun it can be.
|
|
|
|
|
Please, can you show me an example??
Thank you so much!
|
|
|
|
|
|
How is the text file below (% java BinarySearch largeW.txt < largeT.txt) read as "args[0]". Code snippet would be apprecated
public static void main(String[] args)
{
int[] whitelist = In.readInts(args[0]);
Arrays.sort(whitelist);
while (!StdIn.isEmpty())
{
int key = StdIn.readInt();
if (rank(key, whitelist) == -1)
StdOut.println(key);
}
}
% java BinarySearch largeW.txt < largeT.txt
499569
984875
...
|
|
|
|
|
args[0] is the file largeW.txt, while largeT.txt will be piped direct into the program as StdIn . I'm not sure what code snippet we can offer since the snippet above explains it so succinctly.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
My question is: How is arg[0] pointing to the text file? Code Snippet would be appreciated
|
|
|
|
|
You have the code snippet, look at the definition of main . The args parameter is set by the framework as an array of strings which correspond to the parameters on the command line.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have written a function in JAVA and i need to call that function from C# .net. While searching on the net, most of them suggesting to use 3rd party(like JNBridge) to create wrapper DLL and that can be referenced in C# .net.
But i don't want to use 3rd party. How to develop a wrapper in order to access java from C#? Any example code may be more helpful.
|
|
|
|
|
I'm afraid you'll need to have some form of bridge software. Have a read of this article[^], it explains the issues and gives you the software you need. Re-inventing the wheel is not a good idea.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
He's already got this answer on the C# forum. I think he has decided to go the JNI route and is looking for pointers on that so has re-posted here.
modified 11-Jan-12 8:06am.
|
|
|
|
|
now the question is not if or how a JAVA function can be called in C#.
The real question must be: why? Why did you write "a function" in JAVA? Why didn't you write "a function" in C# as you are using C# surround "a function".
And beside of that am I wondering what "a function" might be and why it is called directly from a C# code.
Java can be a mighty beauty when written by an expert, but it needs a little more than "a function"-header to address a java code. Isn't there any network related stuff involved?
|
|
|
|
|
Becoz JAVA has classes to support zip file compresion/decompression of multiple files. The same feature is not available in C#. Only through 3rd party its achivable. So i prefer to write a dll in java and use it in C#. Is there any alternate solutions?
|
|
|
|
|
one can not zip multiple files in C#???
Not really true eh! Think about it. This MUST be possible. Ask the C# guys.
Using some Java code found on the web in a C# environment can't be a solution.
|
|
|
|
|
This article may get you started:
How to Call Java Functions from C Using JNI[^]
It's a bit basic but it might at least point you in the right direction.
But JNI programming is not straight-forward at the best of times, and the benefits of using a third-party tool are that they have worked out all the difficult bits, and it may end up being cheaper in the long run to buy something off the shelf than to spend ages building your own.
|
|
|
|
|
Thanks to all for the suggesstions.
|
|
|
|
|
Hi all,
I have a project that I need to making data of sunspot wireless sensor device available via a Restful web service.
I created restful web services in netbeens that contain a classes like restful servlet. Now I want to use the program from the sun spot(send data demo host application) on that servlet. I should do these
@override
public void init(){
// use code from send datademohostapplication
//let run method from the example run as a thread.
}
in my servlet. But I don't know how to do. Is there any Idea.
thanks in advance.
|
|
|
|
|
i want to create gps system using JAVA code . but i dont know hw to start..need help..
|
|
|
|
|
Try this[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|