import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
public class H2O {
//using blocking queue, so it's easy to just have 2 h and 1 o at most,
//other threads will be blocked.
ArrayBlockingQueue
网友真的很有才啊
原英语版本
My enemies are many,my equals are none. In the shade of olive trees,they
said Italy could never be conquered.In the land of pharoahs and kings, they
said Egypt could never be humbled.In the realm of forest and snow,they said
russia could never be tamed.Now they say nothing.They fear me ,like a force
of nature,a dealer in thunder and death.I say I am Napoleon,I am emperor....
....Burn it.
正常翻译版
我树敌无数,却从未逢对手。在橄榄树荫下,他们说意大利永远不会被征服。在法老和
国王的土地上,他们说埃及永远不会臣服。在森林与暴雪的国度,他们说俄国永远不会
被征服。现在他们... 阅读全帖
【肖氏术最新消息】ACH的双盲随机对照肖氏手术实验正式启动
Iamback:
信誉死的惨败:ACH的双盲随机对照肖氏手术实验,正式启动
在3月份脊柱裂协会第二届世界大会上,ACH的医生宣布,双盲随机对照的肖氏反射弧临
床实验,20名病人已经招募到齐,IRB也批准了实验。
½ Detethering (D)
½ Detethering + Xiao Procedure (D + X)
(D + X) – D = X
这个临床实验,不过结果如何,都是在人类和疾病做斗争过程中值得探索的步骤。
可是,信誉死的恶棍们,千方百计阻扰这个临床实验的进行,写了很多黑函。
我记得,信誉死一次次宣布ACH的双盲随机对照试验被取消了。
他们阻扰科学进展的努力,犹如螳臂当车。
------------
Current Status of ACH Trials
All Children’s Hospital and Johns Hopkins Medicine
St. Petersburg, FL
Both IRB Approved
Randomized Spina Bifida T... 阅读全帖
when a member function is called, "this" pointer is implicitly passed as
argument.It is part of function signature. Therefore
void func() const;//say "*this" will not be changed.
void func(); //"*this" may or may not be changed.
void main()
{
test a;
a.func(); //call void func();
((const A)a).func(); //call void func() const;
(*(const A *)&a).func(); //call void func() const;
}
msdn
The global operator delete function, if declared, takes a single argument
of type void *, which contains a pointer to the object to deallocate. The
return type is void (operator delete cannot return a value). Two forms exist
for class-member operator delete functions:
void operator delete( void * );
void operator delete( void *, size_t );
这里操作符是通常作为function member的操作符,比如+=
class sum//The base class
{
public:
sum(void);
virtual sum& operator+=(const sum&);
virtual void print_result();
virtual ~sum(void);
};
class sum_int ://The derived class
public sum
{
public:
sum_int(void);
sum_int(const int&);
virtual sum_int& operator+=(const sum_int&);
virtual void print_result();
virtual ~sum_int(void);
private:
int value;
};
int main()//The main function
{
int test[] = {1,2,3};
sum_int A(
heihei, in my test:
gcc: -O1
total loops:2000000000
Time for threaded call:00:00:02
Time for non-threaded call:00:00:03
codes:
#include "threading.h"
#include "timer.h"
#include
#include
#include
int M;
void* cal1(void* vp) {
int flag1 = 0;
for (int n = 0; n < M; n++) {
flag1 = 1;
}
}
void* cal2(void* vp) {
int flag2 = 0;
for (int n = 0; n < M; n++) {
flag2 = 1;
}
}
void* cal0(void* vp) {
int flag2 = 0;
for (int n = 0; n < M; n++) {
fla
#include
class A {
public:
void print();
};
void A::print() {
cout << "A.print"<< endl;
}
class B: publicA {
}
int main() {
B obj;
obj.print();
return 0;
}
output is "A.print"
接下来
#include
class A {
public:
virtual void print();
};
void A::print() {
cout << "A.print"<< endl;
}
class B: publicA {
}
void B::print(){ count << "B.print" << endl;}
int main() {
B obj;
obj.print();
return 0;
}
error: no 'void B::print()' member function declared in class 'B'
如果想ov... 阅读全帖
Q1)
what are the variable types in the statement below?
int * x, y;
a) both x and y are of type int *
b) x is of type int* and y is of type int
c) x is of type int and y is of type int*
d) both x and y are of type int
我选的是b
Q2)
which of the following is a correct declaration for a pointer to a function
that returns a double and takes no arguments?
a) double (*ptr_function)(void);
b) double (ptr_function)(void);
c) double ptr_function(void);
d) double *ptr_function(void);
Q3)
Which of the followi... 阅读全帖
Void pointer can be flexibly converted into vary types with the cost of type
cast.
Also, the data structure size is not changing, but a two pointers: one is
the necessary next pointer, the other is datum.
here is the what I said "cost" from one of my favorite person's blog.
"We usualy use void* to implement generic containers in C. To do in this way
, we need to pay an overhead on retrieving data pointed by a void* pointer.
We often, but not always, need a function call for operations on void* d... 阅读全帖
I thought it for a while because it looks interesting.
Although I didn't work through to the final solution, I am pretty sure this
can be solved in compile time by using templates
The idea is creating template functions for all possible number of arguments
a function can have, the limit I believe is 256.
For exmaple: assuming all functions return void.
typedef void(MyClass::*funcany)(...);
int count ( (void (MyClass::*func0)()) fp)
{
if (!static_cast(fp))
return -1;
return ... 阅读全帖