lianchi gao

Greenhorn
+ Follow
since May 12, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by lianchi gao

hi Dear:


My method is to send XX to the client whick you want to send msg to and you don't know if it is alive.

if execute the send XX method ,if the client is inalive, the server must catch a excepthion.

Notice: XX is your protocol like a Heartbeat message between server and client.

hi

i have no idea about your mean in the text ?

Does "a socket " mean a socket server or a client ?

i think if you want to test how many client can be handle with a socket server ,you can make a plan of a stress test, your client code open many thread to

connect to the server ,Notice!! and before every one connectiong ,all the thread wait ,and then connecting together.
Big company Big Shot's Funeral

we have no idea about it

Ulf Dittmer wrote:In other words, nothing special will happen, in particular, the servlet will not be initialized (if that's what you expected to happen). Initialization doesn't happen because the init() method is called - the init() method is called because the servlet is initialized (which is something the servlet container does, not your servlet code).



i think he is right, because you can't control the servlet container.
8 years ago
Hi,all

when you see here,you may be surprise what i want to do,

Nothing,i just express my happyness to join you.

because i find a forum that i can really learn technology about Java.

in the future ,when i have trouble i will distrub some one. 3q first.



i will answer any question that in my scope of ablility,3q again!
8 years ago
code:class Producer implements Runnable{
SyncStack stack;
public Producer(SyncStack s){
stack = s;
}
public void run(){
for(int i=0; i<20; i++){
char c =(char)(Math.random()*26+'A');
stack.push(c);
System.out.println("生产:"+c);
try{ Thread.sleep((int)(Math.random()*100));
}catch(InterruptedException e){}
}
}
}

class Consumer implements Runnable{
SyncStack stack;
public Consumer(SyncStack s){
stack = s;
}
public void run(){
for(int i=0;i<20;i++){
char c = stack.pop();
System.out.println("消费: "+c);
try{ Thread.sleep((int)(Math.random()*1000));
}catch(InterruptedException e){}
}
}
}


class SyncStack{
private int index = 0;
private char []data = new char[6];
public synchronized void push(char c){
while(index == data.length){
try{
this.wait();
}catch(InterruptedException e){}
}
this.notify();
data[index] = c;
index++;
}
public synchronized char pop(){
while(index ==0){
try{
this.wait();
}catch(InterruptedException e){}
}
this.notify();
index--;
return data[index];
}
}

public class SyncTest{
public static void main(String args[]){
SyncStack stack = new SyncStack();
Runnable p=new Producer(stack);
Runnable c = new Consumer(stack);
Thread t1 = new Thread(p);
Thread t2 = new Thread(c);
t1.start();
t2.start();
}
}


i want to know If the implementation of this sentence
"while(index == data.length){try{
this.wait();
}catch(InterruptedException e){}
}"

do the sentence "this.notify(); data[index] = c; index++;" execute???

3q
I would like to ask a question on the junior java not making fun of me

import java.awt.*;
import java.awt.event.*;
public class TestMultiListener implements MouseMotionListener,MouseListener {
Frame f = new Frame("多重监听器测试");
TextField tf = new TextField(30);
public TestMultiListener(){
f.add(new Label("请按下鼠标左键并拖动"), "North");
f.add(tf, "South");
f.setBackground(new Color(120,175,175));
f.addMouseMotionListener(this);
f.addMouseListener(this);
f.setSize(300, 200); f.setVisible(true);
}
public static void main(String args[]) {
TestMultiListener t = new TestMultiListener();
}
public void mouseDragged(MouseEvent e) {
String s = "鼠标拖动到位置(" + e.getX() + "," + e.getY() + ")";
tf.setText(s);
}
public void mouseEntered(MouseEvent e) {
String s = "鼠标已进入窗体";
tf.setText(s);
}
public void mouseExited(MouseEvent e) {
String s = "鼠标已移出窗体";
tf.setText(s);
}
// 未使用的MouseMotionListener和MouseListener接口中的方法,也必须实现
public void mouseMoved(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseClicked(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
}


Here this is what role? how to use it? MouseEvent incident is how to useing "this" came to sniffers?
my english is poor i am chinese. thank you for your answer.waiting on line
10 years ago