Slightly confused about notify method

Hi,
I'm currently studying for the SCJP exam and have 2 questions about the thread notify call.
(1) Is it possible when a thread owns an object lock, i.e. say in synchronized code, that it can call the notify method on a particular thread. For example, say there are 2 threads, names thread1 and thread2, and thead1 obtains object lock, can it call Thread2.notify()? The reason I'm read conflicting web-pages, saying it isn't possible for 1 thread to notify another thread and it is up to Object to decide which thread to invoke, say must use notifyAll() or notify() call. Is this true?
(2) Which thread in following code is Thread.sleep() referring to? Is it the main thread that created 2 threads?
class running extends Thread
     public void run(){
public class fredFlintStone{     
     public static void main(String[] args) {
          running  thread1 = new running();
          running thread2 = new running();
          thread1.start();
          thread2.start();
          try
          //confused here     
        Thread.sleep(12L);
          catch(InterruptedException e)
}Cheers!

its best not to confuse terminology here.
marktheman wrote:
I ... have 2 questions about the thread notify call.Thread is an object which has a notify() method. However you should never use it. You should only use notify() on regular objects.
(1) Is it possible when a thread owns an object lock, A Thread holds a lock, see [http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#holdsLock(java.lang.Object)]
i.e. say in synchronized code, that it can call the notify method on a particular thread. A thread calls notify() on an object not a given thread. (Unless that object is a thread, but don't do that!)
For example, say there are 2 threads, names thread1 and thread2, and thead1 obtains object lock, can it call Thread2.notify()?It can, but it would fail as you can only call notify() on an object you hold the lock to.
The reason I'm read conflicting web-pages, saying it isn't possible for 1 thread to notify another thread It is possible but not in any useful way.
and it is up to Object to decide which thread to invoke,The Object has no say in the matter, its up to the scheduler in the OS.
say must use notifyAll() or notify() call. Is this true?no.
(2) Which thread in following code is Thread.sleep() referring to? The javadoc says "Causes the currently executing thread to sleep". You should always check the documentation for asking that sort of question.

Similar Messages

  • Confused about update method in JComponents

    Hello,
    I'm a bit confused about the update method in JComponents. What I remember from applets was that the update method was called whenever something changed such as a window being dragged across it or something.
    I've written a class that extends a JPanel and overwrites the paint method. Any components I add to it aren't drawn. I can add JComponent.update() methods to my paint() method but this is very inefficient as I'm having repaint() called by a thread 15 times a second. I tried to put the update methods in the JPanels update() but that doesn't work, in fact update isn't called at all. What does update do ?

    Let me take another crack at it...
    1) Grab the 9.2.0.8 patchset for the Oracle database (i.e. patch 4547809 on Metalink assuming you're using 32-bit Windows). Install this to upgrade your Oracle client to 9.2.0.8. Installation instructions are in the README.
    2) Grab the 9.2.0.8 Oracle ODBC driver, which you already appear to have, and follow the installation instructions in the README you're looking at.
    Justin

  • I'm confused about accessor methods.

    Part of the application I'm developing translates a sequence of strings into a series of hex values. The number of strings will be either 2 or 3. In the cass where there's 3 strings the last would represent an integer or a decimal fraction.
    I have a class Xlate that has 3 translation methods thus:
    public int[] translate(String msg) {};
    public int[] translate(String msg, int val) {};
    public int[] translate(String msg, String aValString) {};
    The problem I have is that the Xlate does not return what is expected when passed an argument via the method signature. If explicitly passed a string sequence it works OK.
    If I pass the argumants... "pause" "21.09876"
    I would expect to see a translation of ... "msg translation array = 76,98,10,20,0A"
    What I get is "msg translation array = FF, FF, FF, FF,FF" which indicates the array has not been amended after initialised.
    This is most likely due to the lack of accessor definitions and their use. HOWEVER, I am confused by such methods.
    I now realise that to pass values setter/getter accessor methods are .
    I think these might be along the lines of the following:
    private String[] commandList; // declares a string variable
    public Xlate() { this(""); }
    public Xlate(String[] msg) { this.commandList = msg[1]; } // holds the name
    public String getCommandStrings() { return this.commandList; } // gets the commandList
    I can't get this to work and know these are not correct.
    I need help to get me moving ahead of this problem. Any help would be appreciated.
    Thanks.
    Philip
    import java.lang.String;
    public class Control {
      public Control() {
       int i;
      static final public Xlate x = new Xlate();
    //  static final public Comms rc = new Comms();
      public static void main(String[] args) {
        String cmd[] =  args;
        for (int i=0;i<args.length;i++)
          cmd=args[i];
    controller(cmd);
    // public static void controller(String portName, String command, String parameter) {
    public static void controller(String[] parameters) {
    Control c = new Control();
    int[] msg ={1,1,1,1,1};
    // Booleans 'pragmaN' are used to select/deselect debug statements
    // though would be embedded in the bytecode
    // so these are not compiler directives
    boolean pragma1=true, pragma2=true, pragma3=true; // toggle using !
    int pVal;
    if (pragma1==true) {
    System.out.print("msg array = ");
    for (pVal=0; pVal<4;pVal++)
         System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
    System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
    // rc.setupComPort(parameters[0]); // Configure the port referenced
    msg = x.translate("start"); //*********TRANSLATE()************
    msg = x.translate("pause","12.34567"); //*********TRANSLATE()************
    if (pragma2==true) {
    System.out.print("msg translation array = ");
    for (pVal=0; pVal<4;pVal++)
         System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
    System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
    // rc.writeCmd(msg);
    // Control messages have 3 fixed formats comprising 'a string', 'a string
    // plus an integer' and 'a String plus a String'.
    // For the control messages with an argument a string is constructed before
    // translation by parging the arguments.
    // Do ensure the number of args is greater than 1 and less than 3.
    // Converts integer types to Strings
    String argString="";
    System.out.println("arg len = "+ parameters.length);;
    switch (parameters.length) {
    case 2:
         System.out.println("in switch 2");;
         argString = (parameters[1]);
         msg = x.translate(argString); //*********TRANSLATE()************
         if (pragma3==true) {
         System.out.print("msg translation array = ");
         for (pVal=0; pVal<4;pVal++)
         System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
         System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
         break;
    case 3:
         if (pragma3==true) {
         System.out.println("in switch 3"); ;
         argString = (parameters[1] + parameters[2]);
         msg = x.translate(argString); //*********TRANSLATE()************
         if (pragma3==true) {
         System.out.print("msg translation array = ");
         for (pVal=0; pVal<4;pVal++)
         System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
         System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
         break;
    default:
         System.out.println("Argument length error");
    break;
    // rc.writeCmd(msg);
    import java.text.*;
    import java.text.StringCharacterIterator; // required for CharacterIterator class
    public class Xlate {
    private String[] commandList; // declares a string variable
    public Xlate() { this(""); }
    public Xlate(String[] msg) { this.commandList = msg[1]; } // holds the name
    public String getCommandStrings() { return this.commandList; } // gets the commandList
    // These methods form a basic translation mechanism used as proof
    public int[] translate(String msg) {
    int[] paramList = {
         0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; //initialise this array
    //Power On and Off controls
    if (msg == "start") {
    paramList = new int[] {
         0xFF, 0xFF, 0xFF, 0x01, 0x20};
    if (msg == "stop") {
    paramList = new int[] {
         0xFF, 0xFF, 0xFF, 0x00, 0x20};
    return (paramList);
    public int[] translate(String msg, int val) {
    int[] paramList = {};
    int pVal;
    // Memory recall with memory ID.
    if (msg == "M") { // Recall memory
    paramList = new int[] {
         0xFF, 0xFF, 0xFF, 0xFF, 0x02};
    // stuff the argument in to the paramList array
    paramList[3] = Integer.decode(Integer.toHexString(val)).shortValue();
    return (paramList);
      public int[] translate(String msg, String aValString) {
    // Convert the string
        int i, j, k;
        int index = 0, c = 0;
        int[] p, paramList = {};
        final StringBuffer result = new StringBuffer(); // only ever one buffer
        char character;
        if (msg == "pause") {
          paramList = new int[] {
           0xFF, 0xFF, 0xFF, 0xFF, 0x0A};
    // The period character is the axle where operations centre...
    // working from the left most position index until period is found.
    // append chars to result string en route.
    // if period then stop - this is the integer part
        StringCharacterIterator sci = new StringCharacterIterator(aValString);
        result.append('0'); // a fudge to pad out the resulting string
        character = sci.current();
        while (character != '.') {
          //char is not a period so append to buffer
          result.append(character);
          character = sci.next();
        character = sci.next();
    // working from the position of 'the period character' append chars to result string en route.
    // stop at the end having bound the fraction part
        while (character != StringCharacterIterator.DONE) {
          result.append(character);
          character = sci.next();
        aValString = result.toString(); // save the result
        sci = new StringCharacterIterator(aValString);
        String[] part = {
         "00", "00", "00", "00"}; // array index ordered 0 to 3 from left to right
        result.delete(0, result.capacity()); // initialise the StringBuffer result
        character = sci.first();
        for (index = 0; index <= 3; ++index) {
          for (i = 0; i <= 1; ++i) {
         if (character != StringCharacterIterator.DONE) {
           result.append(character);
           character = sci.next();
         else {
           result.append('0');
          part[index] = result.toString();
          result.delete(0, result.capacity()); // initialise the StringBuffer result
    // the sequence handles the conversion of decimal to packed BCD for transmission
        for (k = 0; k <= 3; k++) {
          // cast the String in the array part indexed by k to an int
          i = Integer.parseInt(part[k]);
          for (j = 0; j < 10; j++) {
         if ( (i >= (j * 10)) & (i < ( (j + 1) * 10))) {
           paramList[k] = (j * 0x10 + (i - (j * 10)));
        return (paramList);

    Sorry, this is way too much to look at (at least for me). Please create a small test function that fails & post the formatted code. In doing this, you may even spot the problem yourself!

  • Confused about BatchInteract method

    I am using a web service and the DI Server API to connect to the SBO database. I am able to login and to use the Interact method, but I have problems using the BatchInteract method. I think, my xml document has some failures. Can someone give me an example of a working batchinteract xml document?

    Hi Nico,
    I'm in the process of using the DI Server to create GL Accounts. Here is a copy of the XML that I'm using to create the GL Entries.
    <?xml version="1.0" encoding="UTF-16"?>
    <env:Envelopes xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Envelope>
         <env:Header>
              <SessionID></SessionID>
         </env:Header>
         <env:Body>
         <dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS" CommandID="Add GL Account">
         <BOM>
         <BO>
         <AdmInfo>
              <Object>oChartOfAccounts</Object>
         </AdmInfo>
         <ChartOfAccounts>
              <row>
                   <Name></Name>
                   <FatherAccountKey></FatherAccountKey>
                   <FormatCode></FormatCode>
              </row>
         </ChartOfAccounts>
         </BO>
         </BOM>
         </dis:AddObject>
         </env:Body>
    </env:Envelope>
    <env:Envelope>
         <env:Header>
              <SessionID></SessionID>
         </env:Header>
         <env:Body>
         <dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS" CommandID="Add GL Account">
         <BOM>
         <BO>
         <AdmInfo>
              <Object>oChartOfAccounts</Object>
         </AdmInfo>
         <ChartOfAccounts>
              <row>
                   <Name></Name>
                   <FatherAccountKey></FatherAccountKey>
                   <FormatCode></FormatCode>
              </row>
         </ChartOfAccounts>
         </BO>
         </BOM>     
         </dis:AddObject>
         </env:Body>
    </env:Envelope>
    </env:Envelopes>
    Please let me know if this helps.
    Thank You
    Stephen Sjostrom

  • Confused about extending the Sprite class

    Howdy --
    I'm learning object oriented programming with ActionScript and am confused about the Sprite class and OO in general.
    My understanding is that the Sprite class allows you to group a set of objects together so that you can manipulate all of the objects simultaneously.
    I've been exploring the Open Flash Chart code and notice that the main class extends the Sprite class:
    public class Base extends Sprite {
    What does this enable you to do?
    Also, on a related note, how do I draw, say, a line once I've extended it?
    Without extending Sprite I could write:
    var graphContainer:Sprite = new Sprite();
    var newLine:Graphics = graphContainer.graphics;
    And it would work fine. Once I extend the Sprite class, I'm lost. How do I modify that code so that it still draws a line? I tried:
    var newLine:Graphics = this.graphics;
    My understanding is that since I'm extending the Sprite class, I should still be able to call its graphics method (or property? I have no idea). But, it yells at me, saying "1046: Type was not found or was not a compile-time constant: Graphics.

    Thanks -- that helped get rid of the error, I really appreciate it.
    Alas, I am still confused about the extended Sprite class.
    Here's my code so far. I want to draw an x-axis:
    package charts {
        import flash.display.Sprite;
        import flash.display.Graphics;
        public class Chart extends Sprite {
            // Attributes
            public var chartName:String;
            // Constructor
            public function Chart(width:Number, height:Number) {
                this.width = width;
                this.height = height;
            // Methods
            public function render() {
                drawAxis();
            public function drawAxis() {
                var newLine:Graphics = this.graphics;
                newLine.lineStyle(1, 0x000000);
                newLine.moveTo(0, 100);
                newLine.lineTo(100, 100);
    I instantiate Chart by saying var myChart:Chart = new Chart(); then I say myChart.render(); hoping that it will draw the axis, but nothing happens.
    I know I need the addChild method somewhere in here but I can't figure out where or what the parameter is, which goes back to my confusion regarding the extended Sprite class.
    I'll get this eventually =)

  • Confused about passing by reference and passing by valule

    Hi,
    I am confuse about passing by reference and passing by value. I though objects are always passed by reference. But I find out that its true for java.sql.PreparedStatement but not for java.lang.String. How come when both are objects?
    Thanks

    Hi,
    I am confuse about passing by reference and passing
    by value. I though objects are always passed by
    reference. But I find out that its true for
    java.sql.PreparedStatement but not for
    java.lang.String. How come when both are objects?
    ThanksPass by value implies that the actual parameter is copied and that copy is used as the formal parameter (that is, the method is operating on a copy of what was passed in)
    Pass by reference means that the actual parameter is the formal parameter (that is, the method is operating on the thing which is passed in).
    In Java, you never, ever deal with objects - only references to objects. And Java always, always makes a copy of the actual parameter and uses that as the formal parameter, so Java is always, always pass by value using the standard definition of the term. However, since manipulating an object's state via any reference that refers to that object produces the same effect, changes to the object's state via the copied reference are visible to the calling code, which is what leads some folk to think of java as passing objects by reference, even though a) java doesn't pass objects at all and b) java doesn't do pass by reference. It passes object references by value.
    I've no idea what you're talking about wrt PreparedStatement, but String is immutable, so you can't change its state at all, so maybe that's what's tripping you up?
    Good Luck
    Lee
    PS: I will venture a guess that this is the 3rd reply. Let's see...
    Ok, second. Close enough.
    Yeah, good on yer mlk, At least I beat Jos.
    Message was edited by:
    tsith

  • Newbie question about abstract methods

    hey, I'm working on a web application that I was given and I'm a little confused about
    some of the code in some of the classes. These are some methods in this abstract class. I don't understand
    how this post method works if the method it's calling is declared abstract. Could someone please tell me how this works?
        public final Representation post(Representation entity, Variant variant) throws ResourceException {
            prePostAuthorization(entity);
            if (!authorizeGet()) {
                return doUnauthenticatedGet(variant);
            } else {
                return doAuthenticatedPost(entity, variant);
    protected abstract boolean authorizeGet();Thanks
    Edited by: saru88 on Aug 10, 2010 8:09 PM

    Abstract Methods specify the requirements, but to Implement the functionality later.
    So with abstract methods or classes it is possible to seperate the design from the implementation in a software project.
    Abstract methods are always used together with extended classes, so I am pretty sure that you are using another class.
    Btw: Please post the Code Keyword in these brackets:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

  • [SOLVED] Confused about Mobility Radeon HD 3200

    I've always found hard to find good information about this card - some sources, even, contradict themselves. All what I know is that it is an integrated graphics card and that it features the RS780M chipset. These are some tips I've got from the system logs:
    grep -i r600 /var/log/Xorg.0.log
    [ 23.353] (II) RADEON(0): [DRI2] DRI driver: r600
    [ 23.353] (II) RADEON(0): [DRI2] VDPAU driver: r600
    [ 24.099] (II) AIGLX: Loaded and initialized r600
    dmesg | grep -i radeon
    [ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-linux-hf root=UUID=ab92c2db-22b5-4fcb-a33f-2efe3f3f104c ro radeon.modeset=1 radeon.benchmark=0 radeon.tv=0 radeon.pm=0 init=/usr/lib/systemd/systemd quiet
    [ 0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-linux-hf root=UUID=ab92c2db-22b5-4fcb-a33f-2efe3f3f104c ro radeon.modeset=1 radeon.benchmark=0 radeon.tv=0 radeon.pm=0 init=/usr/lib/systemd/systemd quiet
    [ 1.463857] [drm] radeon kernel modesetting enabled.
    [ 1.464337] radeon 0000:01:05.0: VRAM: 256M 0x00000000C0000000 - 0x00000000CFFFFFFF (256M used)
    [ 1.464340] radeon 0000:01:05.0: GTT: 512M 0x00000000A0000000 - 0x00000000BFFFFFFF
    [ 1.464779] [drm] radeon: 256M of VRAM memory ready
    [ 1.464781] [drm] radeon: 512M of GTT memory ready.
    [ 1.472494] radeon 0000:01:05.0: WB enabled
    [ 1.472499] radeon 0000:01:05.0: fence driver on ring 0 use gpu addr 0x00000000a0000c00 and cpu addr 0xffff8800374a5c00
    [ 1.472502] radeon 0000:01:05.0: fence driver on ring 3 use gpu addr 0x00000000a0000c0c and cpu addr 0xffff8800374a5c0c
    [ 1.472570] [drm] radeon: irq initialized.
    [ 1.472672] radeon 0000:01:05.0: setting latency timer to 64
    [ 1.504277] [drm] radeon atom DIG backlight initialized
    [ 1.504279] [drm] Radeon Display Connectors
    [ 1.504311] [drm] radeon: power management initialized
    [ 2.344989] fbcon: radeondrmfb (fb0) is primary device
    [ 2.441483] radeon 0000:01:05.0: fb0: radeondrmfb frame buffer device
    [ 2.441486] radeon 0000:01:05.0: registered panic notifier
    [ 2.441502] [drm] Initialized radeon 2.30.0 20080528 for 0000:01:05.0 on minor 0
    I also found good (?) information, or at least a clearly-explained article, here. After reading it, UVD appears as the AMD's counterpart of NVIDIA's VDPAU for video acceleration.
    What I'm not sure about, is:
    -  Does it support video acceleration? I'd like to offload video processing to the GPU, but am not sure if my card and the open-source drivers support it or not. Wikipedia's article about VDPAU states it comes from NVIDIA, but then it says it has an open-source implementation.
    -  What has gallium to do with it? What gallium drivers should I enable in mesa? And what about DRI drivers?
    I configured mesa as follows:
    ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --with-dri-driverdir=/usr/lib/xorg/modules/dri \
    --with-gallium-drivers=r600 \
    --with-dri-drivers=radeon \
    --with-llvm-shared-libs \
    --enable-gallium-llvm \
    --enable-egl \
    --enable-gallium-egl \
    --with-egl-platforms=x11,drm \
    --enable-shared-glapi \
    --enable-gbm \
    --enable-glx-tls \
    --enable-dri \
    --enable-glx \
    --enable-osmesa \
    --enable-texture-float \
    --enable-xa \
    --enable-vdpau
    Not sure if I missed something, though.
    I am very confused about how Linux manages graphics, and what all those layers are for. DRM, DRI, VDPAU, VA-API, gl, gl3, xv, xvmc... it's a mess!
    Thanks in advance.
    Last edited by Kalrish (2013-06-16 17:54:04)

    The feature matrix might help. The easy part to answer is that the 3D driver is split into two parts: DRM which is part of the kernel and DRI which is in userspace and comes from the mesa package.
    Xv is an Xserver extension supported by pretty much all drivers. Found in the DDX (xf86-video-*), it uses features of the card to speed up the display of video (but not decoding). It can either do this by using the "video overlay" or creating a shader.
    Now if you want to use Xv but also offload decoding to the card, you need a video acceleration API. The ones to choose from are XvMC, VA-API, VDAPU in increasing order of feature support. They were developed by Xorg, Intel, Nvidia respectively but anyone is free to implement them. I don't think it's correct to call UVD a counterpart of VDPAU. UVD is a bunch of registers on newer AMD cards. And if you sent bits to those registers in the right way, you can implement VDPAU.
    The other way to implement VDPAU (say if the documentation for UVD registers was not released) is to use gallium. There is a gallium state tracker which can still do it at the expense of being slower. It is a hack whereby you convert video frames to polygon textures and make the OpenGL part of the card think that it's calculating part of a 3D scene when really it's decoding video.

  • Confusion about TreeMap

    Hi,
    I'm currently studying for SCJP exam and am confused about the following code.
         public static void main(String[] args) {
         TreeMap myMap = new TreeMap();
         myMap.put("ab", 10);
         myMap.put("cd", 5);
         myMap.put("ca", 30);
         myMap.put("az",20);
         NavigableMap myMap2 = myMap.headMap("cd", true);
         myMap.put("bl",100);
         myMap.put("hi",100);
         myMap2.put("bi", 100);
         System.out.println(myMap.size() + " " + myMap2.size());
         }When I run it, it outputs 7 6.
    What I'm confused about is how when after the line NavigableMap myMap2 = myMap.headMap("cd", true);and values are being entered into the myMap object, that it is still possible for them to be entered in the NavigableMap object? Are the 2 entities not seen seperately? Is it to do with the "inclusive" field of the headMap method.
    The solution states that the myMap contains the objects "ab","cd","ca","az","b1","h1","bi"
    and myMap2 "ab","cd","ca","az","b1","bi".
    But how when adding key-value pairs do both objects (myMap,myMap2) get considered for putting into?
    Thanks.

    From the API:
    headMap
    public NavigableMap<K,V> headMap(K toKey,
    boolean inclusive)
    Description copied from interface: NavigableMap
    Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map >supports all optional map operations that this map supports. So myMap2 contains all the elements from myMap that are <= "cd" (which are all except "hi"), and changes in either map are reflected on both, as stated.

  • Basic Cryptography Question about Cryptograpic Methodes

    Hi
    I have some text data that i need to encrypt and save to a file (kind of a licence file). Than that file is distributed with the software. Upon runtime the software should be able to read in that crypted data file and decrypt it so it can read the information for use.
    I know how this is done using DES for example. But with DES i have to distribute the DES Key with the software, so everbody could use that key to create new encrypted data files.
    What i'm looking for is something like a key i can use to encrypt the data and another key that can only be used to decrypt the data but not for encrypting it, so i can destribute that key with the software with out the danger that anybody can use that key to create new data (licence) files.
    Is there a cryptography mehtode to do this? If yes, is that methode available in JCE?
    I'm a newbie to crypthography, i just read little about the basic concepts, so i'm very thankful about your help.

    I'm not sure whether i understand what you mean. I don't see a reason why i have to exchange any kind of data with the client.
    i thought i package the public key and the encrypted data file with the software i distribute. Than, upon runtime the software loads the public key (as a serialized object) and the encrypted data file and decryptes the data file.
    But this just fits my needs, if the public key may just be used to decrypt the crypted data file and not for encryption. I'm a little bit confused about this point, because i read a lot in the past hours about this topic and the statement was, that private keys are used to decrypt and public keys are used to encrypt. So what i need is the opposite. And i couldn't find such an algorithm until know.
    Maybe you can help me to see that a little bit clearer?
    Thanks a lot for your help!

  • Confused about JTable::setCellEditor

    Hi
    I'm a bit confused about what JTable::setCellEditor does.
    I wrote my own TableCellEditor implementation which can handle dates and other additional stuff and which can decide for itself what type of editing control to display.
    Now I want my table to use only this editor.
    However using
    tblTest.setCellEditor( MyEditorInstance );didn't work. But when I used
    tblTest.getColumnModel().getColumn(0).setCellEditor( MyEditorInstance );
    tblTest.getColumnModel().getColumn(1).setCellEditor( MyEditorInstance );
    tblTest.getColumnModel().getColumn(2).setCellEditor( MyEditorInstance );for every column it worked fine.
    How can I avoid setting the default editor manually and set it for all columns?
    As always, any help is greatly appreciated
    Marcus

    I agree with you, its not clear what that method does.
    If you don't set a cell editor to a column then JTable determines which of its default editors to use based on the Class returned from the getColumnClass() method, which is defined by the JTable and the TableModel. If you are using the default implementation of this method then it will always return Object as the class type. You can use your editor as the default by doing:
    table.setDefaultEditor(Object.class, MyEditorInstance);

  • Confusion about applet

    sir
    i have confusion about applet that if an applet compile successfully but on running it shows a exception message about "main"that no such method exist.help me out please

    The full text of the error message would make it easier for us to see what is wrong BUT it sounds like you are trying to run the Applet as an applicaiton from the comand line rather than through an HTML tag in an HTML page loaded into your browser!
    Though you can make Applets run as applications it not normal to do so.

  • Printable iTunes & still confused about cd artwork

    Hiya,
    Is there a way to have iTunes print out all of the info for the cds I have in it? Mainly artist and album title. It'd save filing them into something like Excel for my records.
    Also, I'm still confused about the artwork iTunes plugs in for my cds. Either it doesn't have the artwork or its wrong. I know I can delete it, but replacing it is what I can't figure out. I was told to drag and drop it into the artwork viewer, but drag and drop it from where? The iTunes music store? My own file (which I tried and it doesn't work)? I tried opening two windows of iTunes to try the drag/drop, but that doesn't work either.
    One last thing, I don't like the new back-up feature of burning cds of my catalog, instead I copy the entire thing onto an external hard drive. Is there an easier way to do this? I know I have to save all of the iTunes info so that my playlists still show up, but when all I mainly need to do is save any new music & playlists I find it takes so long because I have to end up re-saving everything (and at over 11k songs, that takes a while). Any suggestions to help speed up the process?
    Always grateful,
    Tony Adams

    The iTunes method isn't obsolete for everybody, but it's something you don't need to worry about unless you were already using it or you want to exchange data belonging to apps that do not (yet) support iCloud.
    Being able to flag one of your own responses as helpful or as a solution may seem strange, but it has a possible useful application. If you found a clue or an answer in another venue and returned here to report it, you could flag your report as helpful or a solution to give credit to the other venue or the person who entered it there. You aren't supposed to be able to give yourself points, though.

  • [MSI Z97 Xpower AC] Confusion about about BIOS updating...

    So I am a newb who has just finished his first build, using the "MSI Z97 Xpower AC" motherboard (purchased last month).
    The first thing I want to do is update the BIOS.
    But I am a little confused about how I should proceed.
    In the manual, it describes the "M-Flash" method for updating BIOS.
    But as I was reading reviews of this motherboard, there was some talk about the manual being "out-dated" in regards to BIOS update instructions. Some people suggested using some "forum method" for updating. I also see this topic which provides an alternative method for updating the BIOS:
    https://forum-en.msi.com/index.php?topic=172772.0
    So how do you think I should proceed with updating the BIOS?
    Really, what is the safest method?

    Quote from: JLio01 on 31-March-15, 07:54:03
    Forum tool is safer, M-Flash is easier. (my pov..)
    I agree with that. Although for this motherboard (any with Dual BIOS), it should not matter whether it's safer or not, as you can always restore bricked BIOS by using secondary one
    As you are using very first version of BIOS (v1.0) you can either use >>This One<< for MFlash which is latest official available v1.7 from MSI's product website OR for latest official/BETA BIOS to be used with Forum flash tool, you have to ask Svet to prepare a file for you (simply ask for it on current topic)
    But the real question is: do you have any issues with your system that BIOS will fix it?? Because if your reason to flash is "I want latest", then forgive me, but that's the worst "reason" you might ever have.

  • A question about a method with generic bounded type parameter

    Hello everybody,
    Sorry, if I ask a question which seems basic, but
    I'm new to generic types. My problem is about a method
    with a bounded type parameter. Consider the following
    situation:
    abstract class A{     }
    class B extends A{     }
    abstract class C
         public abstract <T extends A>  T  someMethod();
    public class Test extends C
         public <T extends A>  T  someMethod()
              return new B();
    }What I want to do inside the method someMethod in the class Test, is to
    return an instance of the class B.
    Normally, I'm supposed to be able to do that, because an instance of
    B is also an instance of A (because B extends A).
    However I cannot compile this program, and here is the error message:
    Test.java:16: incompatible types
    found   : B
    required: T
                    return new B();
                           ^
    1 errorany idea?
    many thanks,

    Hello again,
    First of all, thank you very much for all the answers. After I posted the comment, I worked on the program
    and I understood that in fact, as spoon_ says the only returned value can be null.
    I'm agree that I asked you a very strange (and a bit stupid) question. Actually, during recent months,
    I have been working with cryptography API Core in Java. I understood that there are classes and
    interfaces for defining keys and key factories specification, such as KeySpec (interface) and
    KeyFactorySpi (abstract class). I wanted to have some experience with these classes in order to
    understand them better. So I created a class implementing the interface KeySpec, following by a
    corresponding Key subclass (with some XOR algorithm that I defined myself) and everything was
    compiled (JDK 1.6) and worked perfectly. Except that, when I wanted to implement a factory spi
    for my classes, I saw for the first time this strange method header:
    protected abstract <T extends KeySpec> T engineGetKeySpec
    (Key key, Class<T> keySpec) throws InvalidKeySpecExceptionThat's why yesterday, I gave you a similar example with the classes A, B, ...
    in order to not to open a complicated security discussion but just to explain the ambiguous
    part for me, that is, the use of T generic parameter.
    The abstract class KeyFactorySpi was defined by Sun Microsystem, in order to give to security
    providers, the possibility to implement cryptography services and algorithms according to a given
    RFC (or whatever technical document). The methods in this class are invoked inside the
    KeyFactory class (If you have installed the JDK sources provided by Sun, You can
    verify this, by looking the source code of the KeyFactory class.) So here the T parameter is a
    key specification, that is, a class that implements the interface KeySpec and this class is often
    defined by the provider and not Sun.
    stefan.schulz wrote:
    >
    If you define the method to return some bound T that extends A, you cannot
    return a B, because T would be declared externally at invocation time.
    The definition of T as is does not make sense at all.>
    He is absolutely right about that, but the problem is, as I said, here we are
    talking about the implementation and not the invocation. The implementation is done
    by the provider whereas the invocation is done by Sun in the class KeyFactory.
    So there are completely separated.
    Therefore I wonder, how a provider can finally impelment this method??
    Besides, dannyyates wrote
    >
    Find whoever wrote the signature and shoot them. Then rewrite their code.
    Actually, before you shoot them, ask them what they were trying to achieve that
    is different from my first suggestion!
    >
    As I said, I didn't choose this method header and I'm completely agree
    with your suggestion, the following method header will do the job very well
    protected abstract KeySpec engineGetKeySpec (Key key, KeySpec key_spec)
    throws InvalidKeySpecException and personally I don't see any interest in using a generic bounded parameter T
    in this method header definition.
    Once agin, thanks a lot for the answers.

Maybe you are looking for