comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* acceptable way to program - 4 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/829184c5bd6bb8b0
* Custom Protocol over TCP - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4b24f908bd6b6b6b
* Socket Thread Question - 5 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5bd730cd6871c0cc
* where is everybody - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b9a589a8cfda9bef
* Best Practices for running J2EE applications on machine with 192 CPUs? - 1 
messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/670df86c61aad2c5
* Tomcat and jTDS - not that stable... - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4c23245a26d17c26
* umm a very newbie question in querys - 6 messages, 4 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/573927d6b5c5fcaa
* help on threads/monitor needed - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cefb56e3aa05046e
* Tuning a distributed application - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7908d3b23227d37d
* Good book on Java basics - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6b796f558b4a9484

==============================================================================
TOPIC: acceptable way to program
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/829184c5bd6bb8b0
==============================================================================

== 1 of 4 ==
Date: Fri, Dec 31 2004 12:32 am
From: DA Morgan  

steve wrote:
> Hi,
> 
> Recently I have been looking at  the various ways people are implementing, 
> interaction between java & oracle databases.
> 
> I was always instructed on the purity of the data model,  "normalize the 
> data" etc.
> 
>  I have seen people Serializing java objects , such as purchase orders 
> orders, customer records etc , then sticking the "object" into am oracle blob 
> column.
> 
> finally when they want to retrieve it they de-serialize the object., work on 
> it then re-serialize and stuff it back into the oracle blob.
> 
> to me this  causes the following problems:
> 
> 1. the object can become very big, and can only be recovered in it's 
> entirety, and if it contains pictures ,etc, it can become huge.
> 2. the object becomes "closed", in that  it cannot be modified or checked in 
> situ
> 3. it cannot be searched , without de-serialization.
> 
> 
> I'm looking to implement a java front end, (oracle back end), system ,that 
> allows a product , to be inspected by an inspection team , and comments/ 
> photographic record kept.
> 
> using an "object approach" would make it very simple, but the size of the 
> resulting object could be very large.
> 
> does anyone have any thoughts how to accomplish this task.
> 
> 
> steve

Store relationally and create an API from package procedures to handle
the transactions between the database and the front-end application.

A good rule of thumb is that if you can't use Crystal Reports to query
the database structure with ease ... you have created a nightmare. What
you describe, above, is a nightmare.
-- 
Daniel A. Morgan
University of Washington
[EMAIL PROTECTED]
(replace 'x' with 'u' to respond)



== 2 of 4 ==
Date: Fri, Dec 31 2004 1:35 am
From: "thufir"  

steve wrote:
[..]
> I'm looking to implement a java front end, (oracle back end),
> system ,that
> allows a product , to be inspected by an inspection team , and
> comments/photographic record kept.

so you've decided on a relational database?  yes, Cobb's (?) rules,
first normal form, second... etc apply in that case.  as DA Morgan
(surely not the mathematician, de morgan?) said, the practice you
described is the worst of both worlds:  a total mis-use of a relational
database which, as you state, should be normalized as much as is
practical/possible.

if a (relational) database isn't normalized, to whatever extent, it's
open to corruption.  In the situation you described maintenace is
probably a PITA..?

> using an "object approach" would make it very simple, but the
> size of the resulting object could be very large.

instead of a relational database there're a multitude of options:

POJO (plain old java object)
xml
JDO
...i dunno the rest, but there's gotta be tons!

if you've already decided on a relational database (oracle) then your
question as to how to implement that effectively answers itself in many
regards.

you're real question, i infer:  "what are the alternatives to a
relational database?"  and trying to find the best one for your needs.
however, you seem to have already decided on oracle, so it's more
hypothetical than practical.

--Thufir




== 3 of 4 ==
Date: Fri, Dec 31 2004 10:45 am
From: ByteCoder  

steve wrote:
> Hi,
> 
> Recently I have been looking at  the various ways people are implementing, 
> interaction between java & oracle databases.
> 
> I was always instructed on the purity of the data model,  "normalize the 
> data" etc.
> 
>  I have seen people Serializing java objects , such as purchase orders 
> orders, customer records etc , then sticking the "object" into am oracle blob 
> column.
> 
> finally when they want to retrieve it they de-serialize the object., work on 
> it then re-serialize and stuff it back into the oracle blob.
> 
> to me this  causes the following problems:
> 
> 1. the object can become very big, and can only be recovered in it's 
> entirety, and if it contains pictures ,etc, it can become huge.
> 2. the object becomes "closed", in that  it cannot be modified or checked in 
> situ
> 3. it cannot be searched , without de-serialization.
> 
> 
> I'm looking to implement a java front end, (oracle back end), system ,that 
> allows a product , to be inspected by an inspection team , and comments/ 
> photographic record kept.
> 
> using an "object approach" would make it very simple, but the size of the 
> resulting object could be very large.
> 
> does anyone have any thoughts how to accomplish this task.

As you said above. If you have a proper data model, it should be a piece 
of cake. :)

-- 
-------------
- ByteCoder -           ...I see stupid people
-------------
                    Curiosity *Skilled* the cat



== 4 of 4 ==
Date: Fri, Dec 31 2004 1:51 am
From: "thufir"  

<http://directory.google.com/Top/Computers/Programming/Languages/Java/Databases_and_Persistence/Database_Management_Systems_-_DBMS/Object-Relational/>

<http://objectstyle.org/cayenne/>

<http://www-306.ibm.com/software/data/cloudscape/>

<http://www.hibernate.org/>

in no particular order :)

note that the term "object-relational mapping" is what you're after,
probably.

--Thufir





==============================================================================
TOPIC: Custom Protocol over TCP
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4b24f908bd6b6b6b
==============================================================================

== 1 of 3 ==
Date: Fri, Dec 31 2004 12:34 am
From: "Yamin"  

The issue you will be dealing with is 'endianess'.  Java is pefectly
capable of dealing with it.  Almost any language is.

plain text is a little more interesting.  You will have to choose your
text encoding...which you seem want to use something like UTF-8.
Supposing you do that, once you get down to actually transmitting data,
you will be wasting about twice as much bandwidth.
It takes 2 hexadecimal characters (as text) to uniquely represent one
byte.

Since this is a p2p application, its doubtful you'd want to have
everyone wasting this kind of bandwidth.  I'd go with binary data and
specify the use of network byte order.  Network byte order is the
default for java streams I think as well....so that may help you out as
well.

Yamin




== 2 of 3 ==
Date: Fri, Dec 31 2004 12:33 pm
From: Steve Horsley  

Jeffrey Spoon wrote:
> 
> 
> Hello I was toying with the idea of writing a relatively simple P2P 
> system. I decided using TCP would be the best bet and maybe UDP for 
> discovering other nodes. However, initially I was going to use binary 
> headers for my protocol to keep overhead down, but apparently this is 
> problematic and not at all friendly to anything non-C++, as well as 
> byte-ordering issues etc. Could be an issue as I'll be using Java...

Java and most other languages have no problem with binary data, PROVIDED
that the data format is defined properly. This definition must state
byte-by-byte way what is sent over the wire. The problem comes when lazy
C/C++ programmers send an image of an in-memory structure and don't 
actually KNOW what they are sending over the wire (which would probably 
change if they used a different compiler or different compile options 
against the same source code). It is very hard to decode messages where 
even the sender doesn't know what he's sending, and equally hard to encode 
messages when the recipient doesn't know what format he expects. The same 
issue applies with binary file data transferred between programs, although 
for some reason file contents do tend to get documented more accurately.
  
> 
> Anyway, should I just use plain text for my protocol messages? It still 
> seems wasteful, as you're basically wasting 8 bits with each character, 
> whereas you could stuff a lot more info into a binary packet. I suppose 
> this is more of a general programming/networking question, but since I 
> will be using the Java I thought this was a good place to start.
> 

Unless you have real bandwidth concerns, I would suggest that the easier
debugging will outweigh the extra bandwidth, and that text is probably 
the better choice. It makes the protocol easier for others to understand
too, which is a consideration if you hope for wide adoption.

Text headers also tend to be easier to extend, add to, abuse etc.

Steve



== 3 of 3 ==
Date: Fri, Dec 31 2004 9:03 am
From: Jeffrey Spoon  

In message <[EMAIL PROTECTED]>, 
Yamin <[EMAIL PROTECTED]> writes
>The issue you will be dealing with is 'endianess'.  Java is pefectly
>capable of dealing with it.  Almost any language is.
>
>plain text is a little more interesting.  You will have to choose your
>text encoding...which you seem want to use something like UTF-8.
>Supposing you do that, once you get down to actually transmitting data,
>you will be wasting about twice as much bandwidth.
>It takes 2 hexadecimal characters (as text) to uniquely represent one
>byte.
>
>Since this is a p2p application, its doubtful you'd want to have
>everyone wasting this kind of bandwidth.  I'd go with binary data and
>specify the use of network byte order.  Network byte order is the
>default for java streams I think as well....so that may help you out as
>well.
>
>Yamin
>

Yes I was considering using UTF-8. Although I will actually be GZipping 
the article body to keep bandwidth down (the article headers would be 
too small to bother compressing). But I was considering using the actual 
protocol packets as being binary.

I'm not too sure how to go about this in Java. I take it I would define 
my protocol so a bit does whatever, at whatever offset. Then I create a 
byte, then send it through the byte stream, or send a bunch of bytes for 
a multiple byte header.


Thanks for the help.


-- 
Jeffrey Spoon





==============================================================================
TOPIC: Socket Thread Question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5bd730cd6871c0cc
==============================================================================

== 1 of 5 ==
Date: Fri, Dec 31 2004 3:36 am
From: "Tom Dyess"  

Hi,

    I'm creating a newsreader object for use in the global area of a 
servlet, so it can be used by multiple threads. I only want a single socket 
connection for all threads. For example, a thread would need to talk to the 
socket exclusively through several readLine() and printLn() dialog before 
any other threads can talk to the socket. Once this thread is finished 
communicating through the socket, another thread can communicate to the 
socket. How would I accomplish this?

Thanks,
Tom 





== 2 of 5 ==
Date: Fri, Dec 31 2004 3:59 am
From: "Tom Dyess"  

"Tom Dyess" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
>    I'm creating a newsreader object for use in the global area of a 
> servlet, so it can be used by multiple threads. I only want a single 
> socket connection for all threads. For example, a thread would need to 
> talk to the socket exclusively through several readLine() and printLn() 
> dialog before any other threads can talk to the socket. Once this thread 
> is finished communicating through the socket, another thread can 
> communicate to the socket. How would I accomplish this?
>
> Thanks,
> Tom
>

Well, my first solution was to create these methods and never start a dialog 
until lockSock() returns true. Is this reasonable? Any better ideas?

  private synchronized boolean lockSock() {
    if (!sockLocked) {
      sockLocked = true;
      return true;
    } else {
      return false;
    }
  }
  private synchronized void unlockSock() {
    sockLocked = false;
  }





== 3 of 5 ==
Date: Fri, Dec 31 2004 4:03 am
From: "Tom Dyess"  

"Tom Dyess" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Tom Dyess" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Hi,
>>
>>    I'm creating a newsreader object for use in the global area of a 
>> servlet, so it can be used by multiple threads. I only want a single 
>> socket connection for all threads. For example, a thread would need to 
>> talk to the socket exclusively through several readLine() and printLn() 
>> dialog before any other threads can talk to the socket. Once this thread 
>> is finished communicating through the socket, another thread can 
>> communicate to the socket. How would I accomplish this?
>>
>> Thanks,
>> Tom
>>
>
> Well, my first solution was to create these methods and never start a 
> dialog until lockSock() returns true. Is this reasonable? Any better 
> ideas?
>
>  private synchronized boolean lockSock() {
>    if (!sockLocked) {
>      sockLocked = true;
>      return true;
>    } else {
>      return false;
>    }
>  }
>  private synchronized void unlockSock() {
>    sockLocked = false;
>  }
>
>

Sorry, one more point, I will be communicating with the socket like this

  public synchronized void loadNewsgroups() {
    String group = "";
    newsGroups.clear();
    while (!lockSock()) {} // Keep trying to lock the socket
    try {
      printLine("LIST");
      group = readLine(); // First one is statement of list (not a group)
      if (group.contains("215")) {
        // 215 NewsGroups Follow
       group = readLine(); // prime the while pump with first ng.
       while (group.compareTo(".") != 0) {
         group = readLine();
       }
      }
    } finally {
      unlockSock();
    }
  } 





== 4 of 5 ==
Date: Fri, Dec 31 2004 10:57 am
From: Gordon Beaton  

On Fri, 31 Dec 2004 04:03:53 -0500, Tom Dyess wrote:
>> Well, my first solution was to create these methods and never start
>> a dialog until lockSock() returns true. Is this reasonable? Any
>> better ideas?

Rather than explicitely obtain and release a mutex, why not simply
syncrhonize the sections of code you want to protect.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e



== 5 of 5 ==
Date: Fri, Dec 31 2004 7:43 am
From: "Tom Dyess"  

Because two threads could be asking different things from the socket at the 
same time. Say each thread sent a request that rendered a multi-line 
response. 1 thread wanted a list of message headers and another wanted a 
list of newsgroups and they both hit the socket at the same time, they would 
each get a combination of the intended results and the other thread's 
results even though both methods (get newsgroups and get messages) are each 
individually synchronized. Is this not correct?

What I ended up doing was a singleton object aggregating a socket, a 
locking/unlocking mechanism and an in/out reader/writer. The socket also 
checks to see if it's connected and will reconnect if it isn't (big bonus).

My objectives were:

1. Have a single socket connection
2. Have that connection reconnect itself when disconnected
3. Only allow a single thread to converse indefinately to the connection at 
a time

I think this design will do that - any suggestions/comments?

package com.dysr.tcp;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;


public class NewsConnector {
  static String host = "";
  static int port = 119;
  static String login = "";
  static String password = "";
  static boolean debug = false;
  static private Socket sock = null;
  static private PrintWriter out = null;
  static private BufferedReader in = null;
  static private boolean socketLocked = false;

  static private synchronized void buildConnection() {
    try {
      sock = new Socket(host, port);
      sock.setKeepAlive(true);
      out = new PrintWriter(sock.getOutputStream(), true);
      in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
      authenticate();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  static public Socket getSock() {
    if (sock != null) {
      if (sock.isClosed()) {
        buildConnection();
      }
    } else {
      buildConnection();
    }
    return sock;
  }
  static public BufferedReader getIn() {
    getSock();
    return in;
  }
  static public PrintWriter getOut() {
    getSock();
    return out;
  }
  static synchronized public boolean lockSock() {
    getSock();
    if (!socketLocked) {
      socketLocked = true;
      return true;
    } else {
      return false;
    }
  }
  static void printLine(String line) {
    getOut().println(line);
    if (debug) {
      System.out.println(line);
    }
  }
  static void printLine() {
    printLine("");
  }
  static String readLine() {
    String line = "";
    try {
      line = getIn().readLine();
      if (debug) {
        System.out.println(line);
      }
      return line;
    } catch (Exception e) {
      return "";
    }
  }
  protected static synchronized boolean authenticate() {
    boolean result = true;
    String line = "";
    while (!lockSock()) {}
    try {
      printLine(); // Tell the server there is someone here
      line = readLine(); // the header
      printLine("MODE READER");
     line = readLine();
     // 480 Authentication required for command
     printLine("AUTHINFO USER " + login);
     line = readLine();
     if (line.contains("381")) {
       // 381 More authentication required
       printLine("AUTHINFO PASS " + password);
       line = readLine();
       if (line.contains("281")) {
         // 281 Authentication Accepted
         result = true;
       } else {
         // 502 Authentication rejected
         result = false;
       }
     } else if (line.contains("281")) {
       result = true;
       // TODO: passed with just a user - this may not be the correct code
     }
    } catch (Exception e) {
      result = false;
    } finally {
      unlockSock();
    }
    return result;
  }
  public static synchronized void disconnect() {
    try {
      printLine("QUIT");
      out.close();
      in.close();
      sock.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  static synchronized public void unlockSock() {
    socketLocked = false;
  }
  public static void main(String[] args) {
  }
}


"Gordon Beaton" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Fri, 31 Dec 2004 04:03:53 -0500, Tom Dyess wrote:
>>> Well, my first solution was to create these methods and never start
>>> a dialog until lockSock() returns true. Is this reasonable? Any
>>> better ideas?
>
> Rather than explicitely obtain and release a mutex, why not simply
> syncrhonize the sections of code you want to protect.
>
> /gordon
>
> -- 
> [  do not email me copies of your followups  ]
> g o r d o n + n e w s @  b a l d e r 1 3 . s e 






==============================================================================
TOPIC: where is everybody
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b9a589a8cfda9bef
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 31 2004 9:01 am
From: "Chris Uppal"  

Andrew Thompson wrote:

>
<http://groups-beta.google.com/group/comp.lang.java.programmer/browse_frm/threa
d/b9a589a8cfda9bef#16e265c8816cc85f>

> I hate these new URL's..

Me too.  The whole thing is broken IMO.  (E.g. look at posts from a specific
author, then switch to viewing them in chronological order -- half of them
vanish...)

Grr...

    -- chris






==============================================================================
TOPIC: Best Practices for running J2EE applications on machine with 192 CPUs?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/670df86c61aad2c5
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 31 2004 2:19 am
From: "Cindi"  


Michael Borgwardt wrote:
> Cindi Jenkins wrote:
> > I have seen others comment on writing applications that run on two
or
> > four CPU machines but wanted to know if anyone has uncovered "best
> > practices" for developing Java applications that support 192 CPUs?
>
> Not really all that different from having 2 or 4 - exploit the
parallelism
> in the application by spreading the work over different threads. This
> depends more on the application than on the number of available CPUs,
> the only difference is that it rarely makes sense to have much more
> working threads than CPUs. Be careful about bottlenecks like disk IO.
> Choice and tuning of the JVM is also a much bigger factor than on
> single-CPU systems. You definitely need a JVM that supports parallel
> garbage collection (i.e. have more than one GC thread).

I have access to a JVM that supports parallel garbage collection.
Really looking for software engineering tips maybe explained in a
patterns based way.





==============================================================================
TOPIC: Tomcat and jTDS - not that stable...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4c23245a26d17c26
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 31 2004 11:36 am
From: "Alin Sinpalean via JavaKB.com"  

Rico,

Being part of a Windows domain does not affect jTDS in any way. jTDS is a pure 
Java app and SQL authentication is totally independent of Windows domains. It 
might be the SQL Server configuration or something else.

Alin.

-- 
Message posted via http://www.javakb.com




==============================================================================
TOPIC: umm a very newbie question in querys
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/573927d6b5c5fcaa
==============================================================================

== 1 of 6 ==
Date: Fri, Dec 31 2004 4:36 am
From: "ali"  

well some thing is not right i think

i tried this query
recordSet = query.executeQuery("SELECT * FROM members WHERE Name LIKE
'Ali*'");

and wrote it correctly in try catch

but id didnt work

if i write my complete name instead of 'Ali*' it
works

but with the statment as it is it finds nothing

i think Stetment has some ellargy to * ( any) in sql
so can some help me with a solution for that




== 2 of 6 ==
Date: Fri, Dec 31 2004 1:50 pm
From: karlheinz klingbeil  

ali schrub am Freitag, 31. Dezember 2004 13:36
folgendes:

> i tried this query
> recordSet = query.executeQuery("SELECT * FROM members
> WHERE Name LIKE 'Ali*'");

> i think Stetment has some ellargy to * ( any) in sql
> so can some help me with a solution for that

So why do you ask this question an a java group instead
of a sql group ?

BTW: in most SQL Databases the wildcard Character is %
(not '*')
-- 
greetz Karlheinz Klingbeil (lunqual)
http://www.lunqual.de oder http:www.lunqual.net



== 3 of 6 ==
Date: Fri, Dec 31 2004 6:27 am
From: "ali"  

Thanks

well i didnt knew the information about % is used in most databases i
though it is *

That solved my problem thanks a lot

i asked here because i have almost the same programe in visual basic
and the query worked there with * and didnt work here so though the
problem is in how java deal with sql commands 


thanks again




== 4 of 6 ==
Date: Fri, Dec 31 2004 9:40 am
From: Sudsy  

ali wrote:
<snip>
> i asked here because i have almost the same programe in visual basic
> and the query worked there with * and didnt work here so though the
> problem is in how java deal with sql commands 
<snip>

So you were doing it wrong but M$ was "helping" by translating to the
appropriate wild-card character. Makes you wonder if it translates a
period (used in REs to match a single character) to the underscore
(_) which is the proper wild-card single character match in SQL. But
that wouldn't make sense, would it?...
Bottom line: Don't EVER assume that the way that M$ does something is
the "right" way.



== 5 of 6 ==
Date: Fri, Dec 31 2004 4:07 pm
From: Thomas Kellerer  

Sudsy wrote on 31.12.2004 15:40:
> ali wrote:
> <snip>
> 
>> i asked here because i have almost the same programe in visual basic
>> and the query worked there with * and didnt work here so though the
>> problem is in how java deal with sql commands 
> 
> <snip>
> 
> So you were doing it wrong but M$ was "helping" by translating to the
> appropriate wild-card character. 

I assume (because he used VB) he was using MS Access. In that case he *did* 
it right :)
In Access the wildarcd characters are indeed * and ?

Thomas



== 6 of 6 ==
Date: Fri, Dec 31 2004 10:20 am
From: Sudsy  

Thomas Kellerer wrote:
<snip>
> I assume (because he used VB) he was using MS Access. In that case he 
> *did* it right :)
> In Access the wildarcd characters are indeed * and ?
> 
> Thomas

Then it proves my point, doesn't it? Those are NOT the standard SQL
wild-cards. So you'd need one version of the code for Exlax and one
for all the other, SQL-compliant databases.




==============================================================================
TOPIC: help on threads/monitor needed
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cefb56e3aa05046e
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 31 2004 7:51 am
From: "Matt Humphrey"  


"ByteCoder" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> [EMAIL PROTECTED] wrote:
> > Thanks again ByteCoder!
> > The reason for using different classes (which are 'Runnable') is to
> > handle different Strings comming/going to RS232, as I told before. The
> > structure of the Strings are quite different, which makes it too
> > difficult to handle in one serialEvent method.
> > Could somebody answer to my questions, which I guess are elemantary to
> > all thread freaks out there:
> > Once again:
> > Can I use synchronized (applied to methods) applied in several classes,
> > using one lock (my boolean parameter which I set true and false in the
> > synchronized methods)? My access to the lock would go through the
> > argument passed in the constuctor, to make my lock parameter 'visible'.
> >
> > snippet:
> > public class T1 implements ... {
> > ...
> > private SerialConnection connection;
> >
> > //constructor
> > public T1(SerialConnection connection){
> > this.connection = connection;
> > }
> >
> >
> > public synchronized void serialEvent(SerialPortEvent e) {
> > ...
> >
> > connection.threadActive = false; // is this possible?
> > }
> > }//class
> >
> > In the calss SerialConnection I have declared the attribute
> > public volatile boolean threadActive;  // I use this as lock
> > which is set true in another synchronized method before entering the
> > serialEvent method above
> >
> > Frank
> >
>
>  From your above statements I get the idea you don't really know what
> the synchronized keyword does.
>
> The synchronized keyword is used to prevent any other thread calling the
> synchronized methods/blocks (that's *all* the synchronized methods in a
> class) when one thread is using them. If that one thread is done (the
> method completed) the other threads can use the method again on a first
> come, first serve basis (they don't 'wait in line'). The thread that's
> waiting who 'gets there first' can execute the method.
> This all happens automatically. You only have to specify the
> synchronized keyword before a (or more) method(s).

Don't forget that the monitor belongs to the object.  The same synchronized
method can be called by two different threads if they're being called on
different objects.  For static methods the class object is used.

Cheers,
Matt Humphrey   [EMAIL PROTECTED]  http://www.iviz.com/






==============================================================================
TOPIC: Tuning a distributed application
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7908d3b23227d37d
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 31 2004 4:59 am
From: "silarri"  

Hi everybody,

I would like to know if there is some easy way or tool (free, if
possible) that I could use to monitor the overload (CPU, memory and
network) used by the components of a distributed Java application
running on Linux. Some profiling tool that is easy to use in a
distributed environment?

Sergio





==============================================================================
TOPIC: Good book on Java basics
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6b796f558b4a9484
==============================================================================

== 1 of 2 ==
Date: Fri, Dec 31 2004 2:43 pm
From: "Mr B."  

Hi

Any recommendations on a good book on Java basics ?
I am very experienced in Windows / C++ programming, but have no idea how to 
build bas classes to inherit from etc etc etc etc

Also, I seem to miss some offline helpfiles on the Java methods, stuff like 
setText etc etc
Anything available ?

TIA
Lars 





== 2 of 2 ==
Date: Fri, Dec 31 2004 4:34 pm
From: anonymous  

Mr B. wrote:
> Hi
> 
> Any recommendations on a good book on Java basics ?
> I am very experienced in Windows / C++ programming, but have no idea how to 
> build bas classes to inherit from etc etc etc etc
> 
> Also, I seem to miss some offline helpfiles on the Java methods, stuff like 
> setText etc etc
> Anything available ?
> 
> TIA
> Lars 
> 
> 
'Java in a Nutshell' comes to mind.



==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to